use PHP date function to calculate hours between start and finish time
make a function that takes in to variables
first variable would be time tick started
$date = date("H");
$tickstart = date("H");
$tickamount = 5;
$tickend = $tickstart + $tickamount;
$tickleft = $tickend - $datenow;
if($datenow==$tickend)
{
do stuff
}
the only other thing u need is something that always is refreshing the date!
i would say one big while loop thats always running but i dont know how u would do that
acually that wouldnt be too hard
hmmm something like this
make a new file called clock.php or tick.php
then use something like this
(u could maybe do this a ever repeating loop take up CPU tho. You might want to just include a UPDATE DATE php that when anyone accesses any page in the game that the date is updated. Just like Weed Packet suggested)
<?pho
while(1==1);
{
$datenow = Date("H");
}
?>
then to make sure it updates but remember that the examples here only DO HOURS
if u want something with minutes (100x more accurate)
then you want to store $datanow as an array
array part 1 would be Hours
array part 2 would be minutes
also to do this u must make in the other file script
start u off with something like that!
i dont know if php reads integers such as 01 = 1 or not
but if it does ull need to use split() function i believe to get rid of the leading zeros if that causes a problem (example 01 imploded to 1) 🙂
split() its on http://uk.php.net/manual/en/function.split.php
(the code below is not finished for functional)
$dateh = date("H"); //hours
$datem = date("i"); //for mintues
$tickstarth = date("H"); //start tick time is the hour of start
$tickstartm = date("i"); //start tick time is the minutes of start
$tickamount = 5;
$tickend = $tickstart + $tickamount;
$tickleft = $tickend - $datenow;
if($datenow==$tickend)
{
do stuff
}
also it might be easier to get the minutes and hours at the same time and simply use the implode to SPLIT the
$date = ("H:i");
u would go something like
<?php
list($hours, $minutes) = split (":", $Date, 2);
?>
in the list(here) u want to put the variables u want to store the split data in
in split(":" is the thing u split them at $Date is the variable u want spit
and 2 is the limit of elements ur taking out of the variable $Date
i hope this helps
I LOVE PHP i have been coding php for maybe a month and im 1/4 done my php forums hehehe
GOOD luck with ur game