Hiya, i need help with a php countdown script that is supposed to echo a time to the next reset (which is every 4 hours starting from 12:00 AM).
Heres what i got at the moment and im trying to get it right because at the moment its saying i got 9hours left to the next reset. This is wrong because the next reset is always every 4 hours. Heres my code...
<?php
$gettime= gmdate('h');
if ($gettime > "00" && $gettime < "04"){
$times="4";
}elseif ($gettime > "04" && $gettime < "08"){
$times="8";
}elseif ($gettime > "08" && $gettime < "12"){
$times="12";
}elseif ($gettime > "12" && $gettime < "16"){
$times="16";
}elseif ($gettime > "16" && $gettime < "20"){
$times="20";
}elseif ($gettime > "20" && $gettime < "23"){
$times="0";
}
countdown($time, 0);
function countdown($time, $minute)
{
$day= gmdate('d');
echo "$day<br>";
// make a unix timestamp for the given date
$the_countdown_date = mktime($day, $hour, $minute, 0);
// get current unix timestamp
$today = gmdate('h i s');
$difference = $the_countdown_date - $today;
if ($difference < 0) $difference = 0;
$days_left = floor($difference/60/60/24);
$hours_left = floor(($difference - $days_left*60*60*24)/60/60);
$minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60);
// OUTPUT
echo "Next reset in: ".$hours_left."h ".$minutes_left."m";
}
?>
I would appreciate it if you can help me with this code. I need it for a txt-based game im making. Thanks