Page 1 of 1

help! (Math) pritty simple i guess...

Posted: Tue Dec 01, 2009 8:41 am
by Goofan
Hi i got this....
I need to make these array´s abit smaller inside :D
Can someone help me with a code to reduce the coding of these array´s?
Shouldnt need all this coding, dont u think?.



And can someone tell me if this can work in practice?

Code: Select all

 
$periods         array("00:30", "01:30", "02:30", "03:30", "04:30", "05:30", "06:30", "07:30", "08:30", "09:30", "10:30", "11:30", "12:30", "13:30", "14:30", "15:30", "16:30", "17:30", "18:30", "19:30", "20:30", "21:30", "22:30", "23:30")
 
 
$today = date("H:i");
 
if $today = $periods then
{
uppdate..... pengar=$pengar + 30000
}
 
calculate...
 on my second "project i need to make a countdown....
so saying like when date("i")
so that when date turn a minute it will go down one like:
$time = 60
$time = $time - 1
untill $time = 0 then start over when a minute has passed...

 



-Thanks in advance
-Thomas

Re: help! (Math) pritty simple i guess...

Posted: Tue Dec 01, 2009 8:48 am
by papa
You can take a look at: http://us.php.net/manual/en/function.mktime.php

mktime()

if you want a 30 minute interval for example it's pretty easy to implement and change.

Re: help! (Math) pritty simple i guess...

Posted: Tue Dec 01, 2009 8:57 am
by Goofan
well i dont get how u change it so that it work like i wanted it to...
Dont really know anything about mktime.
the code would look like run uppdate......
when date("H:i:s") = mktime(0, 30, 0, 0, 0, 0)


plz make a sample code for me as i dont get the "idé" into my head on how it really works as i need it to.




i thought my idé would work wouldnt it?
all i need would be (my coding) to make the math for the array... so that it wount be such a long code...

...Wouldnt mine work?

Re: help! (Math) pritty simple i guess...

Posted: Tue Dec 01, 2009 9:07 am
by papa
I'm not sure what you want to use it for? I would make a simple counter with javascript that counts down without reloading the page.

Also using the date functions you can get a more dynamic and accurate result:

Code: Select all

$now = date("params")
$30_mins_from_now = $now + 30/code]

Not the correct synthax, but you might get the picture.

Re: help! (Math) pritty simple i guess...

Posted: Tue Dec 01, 2009 9:12 am
by Goofan
What i want it to do is:

i want the date to work.... so that everytime the date get to like 00:30 it will add aditional 30000 into a database (this is a game im building) and then when it hits 01:00 it does it again this way i can add it by automation...

and i dont know what to type with javascript to get a counter... so that it works my way :D

Re: help! (Math) pritty simple i guess...

Posted: Tue Dec 01, 2009 9:15 am
by papa
Aha,

Neither javascript or php will help you here I'm afraid.

Cron

Have no experience myself, but Cron might do the trick.

Re: help! (Math) pritty simple i guess...

Posted: Tue Dec 01, 2009 9:16 am
by Goofan
ahh i dont get cron....i have talked to other about it but i dont get it.... need a basic script to help on that part...

Re: help! (Math) pritty simple i guess...

Posted: Tue Dec 01, 2009 9:17 am
by Goofan
ill start a thread about "Cron!!!" if u need to get a better insight in to cron aswell :D