#native_company# #native_desc#

Date/Time Count Down

By Tom Gard
on January 9, 2001

Version: 1.27

Type: Sample Code (HOWTO)

Category: Calendars/Dates

License: GNU General Public License

Description: PHP Count down days:hours:minutes:seconds between current date/time and future date/time. I’m a newbie and would appreciate any feedback on my code. Perhaps there is a better/simpler way to do this in php and if so please fill me in, thanks.

//Count Down of Days:Hours:Minutes:Seconds
//by T.Gard ([email protected]) written 01/09/2001
//Date/Time counting down too.
$datetime=strtotime( "2001-01-27 11:00" );
//Retrieve the current date/time  

 if ($datetime < $date2) {
     print "The Event is here!! or over with!! <br>  ".$date2." is greater than ".$datetime."<br>";
 } else {
//List total time by type
echo "total seconds remaining: ".(($datetime-$date2)). "<br>";
echo "total minutes remaining: ".(($datetime-$date2)/60). "<br>";
echo "total hours remaining: ".(($datetime-$date2)/3600). "<br>";
//Days - a day is a 24 hour period
//This gives days remaining
echo "total days remaining: ".$holdtotday. "<br>"; 
//Find hours remaining - get days in hours and sub from tothr
echo "hours remaining: ".($holdhr). "<br>";
//Find minutes remaining - get days and hours in minutes and sub from totmin
echo "minutes remaining: ".($holdmr). "<br>";
//Find seconds remaining - get days hours minutes in seconds and sub from totsec
echo "seconds remaining: ".($holdsr). "<br>";