Repeating Timer In PHP
August 5th, 2016
If so please adjust the PHP timer thank you.
<?php
// countdown function
// parameters: (year, month, day, hour, minute)
countdown(2007,12,10,22,0);
function countdown($year, $month, $day, $hour, $minute)
{
// make a unix timestamp for the given date
$the_countdown_date = mktime($hour, $minute, 0, $month, $day, $year, -1);
// get current unix timestamp
$today = time();
$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 "<font color='red' >".$days_left." days ".$hours_left." hours ".$minutes_left." minutes left !!!</font>";
}
?>
You can use an if statement: (this is just an outline, so don’t just copy paste it)
if($today == "sunday")
{
countdown(today stuff here);
}
else
{
$previous_sunday = $today - $sunday_that_passed;
countdown($previous_sunday);
}