I want to stop my php countdown timer to stop at 00:00:00:00
here is my code
$due_date = strtotime('July 4, 2014 10:33 PM');
$rem = $due_date - time();
$day = floor($rem / 86400);
$hr = floor(($rem % 86400) / 3600);
$min = floor(($rem % 3600) / 60);
$sec = ($rem % 60);
echo "$day Days $hr Hours $min Minutes $sec Seconds Remaining...";
but it runs further to -1 and so on in minus values.
i dont want it, I want to stop it at zeros. So I can echo my any msg when it stops at zero. any idea how to do it?
many thanks in advance.
$due_date = strtotime('July 4, 2014 00:33 PM');
if($due_date > time()) {
$rem = $due_date - time();
$day = floor($rem / 86400);
$hr = floor(($rem % 86400) / 3600);
$min = floor(($rem % 3600) / 60);
$sec = ($rem % 60);
echo "$day Days $hr Hours $min Minutes $sec Seconds Remaining..."; // Timer still has time to go.
} else {
echo "0 Days 0 Hours 0 Minutes 0 Seconds Remaining..."; // Timer is finished, now at 00:00:00
}