The simple PHP program below displays a countdown timer between a set start time and a stop time.
1 2 |
<br />/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * PHP Countdown Timer Program<br /> *<br /> */<br /> <br /> <?php<br /> <br /> $targetTime = mktime(17,00,00,07,29,2016); //target stop time in seconds<br /> $currentTime = mktime(9,00,00,07,29,2016); //target stop time in seconds<br /> $difference = $targetTime - $currentTime; //difference between start and stop time in seconds<br /> $hours = (int) ($difference / 3600); //calculate number of hours<br /> $mins = (int) ($difference / 60); //calculate number of minutes<br /> /* if value of mins is greater than 59, divide it by 60<br /> and assign remainder to mins */ <br /> if ($mins --> 59) { <br /> $mins = (int) ($mins % 60); <br /> }<br /> <br /> print "n$hours hour(s) : $mins minute(s)";<br /> <br />?><br /> |
Note that function…