Reputation: 21
Is it possible to create a timer using PHP so that after 60 seconds it does something. So it actually shows you a countdown from 60 to 0. I would refresh the div so it actually looks like it's counting down. I don't mind using JavaScript but I want to run the timer only when the $_GET variable is = to something.
For either option, can anyone help?
For now, I'm using this code I got from EpicSoftworks on Youtube but the problem with this code is that you have to specify the timestamp you want to use.
$future = -2211753540;
$current = time();
$difference = $future - $current;
$minutes = floor($difference/60);
$r_seconds = floor($difference - ($minutes = 60) );
echo '<h2>' . $minutes . ' - ' . $r_seconds . '</h4>';
Upvotes: 1
Views: 2218
Reputation: 31
use PHP to get the variable from the URL and then use javascript for the rest. Create a function that will run a loop 60 times. Inside that loop create a setTimeOut that will do something with a 1000 (1 second) timeout.
Upvotes: 3