note 10546 deleted from function.date by jimw
| From: | jimw@php.net | Date: | Fri, 02 Nov 2001 00:53:22 +0000 |
| Subject: | note 10546 deleted from function.date by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-20069@lists.php.net to get a copy of this message | ||
Im an as/400 programmer myself and am just learning some web stuff on my own. Anyways I was looking
for a Count Down Date function or some code and didnt really find what I was looking for so came up
with a little code that I think is pretty neat. Anyways I was wondering if some of you could email
me some feedback on 1)whether this is fairly intelligently written php code and 2) is there a better
way or some other function that could do this better. I'd appreciate it thanks.
code follows:
<?php
//Count Down of Days:Hours:Minutes:Seconds
//by T.Gard (tom_g@execpc.com) written 01/09/2001
//
//Date/Time counting down too.
$datetime=strtotime( "2001-01-27 11:00" );
//Retrieve the current date/time
$date2=strtotime("NOW");
if ($datetime < $date2) {
print "The Event is here!! or over with!! <br> ".$date2." is greater than
".$datetime."<br>";
} else {
//List total time by type
//Seconds
echo "total seconds remaining: ".(($datetime-$date2)). "<br>";
$holdtotsec=(($datetime-$date2));
//Minutes
echo "total minutes remaining: ".(($datetime-$date2)/60). "<br>";
$holdtotmin=(($datetime-$date2)/60);
//Hours
echo "total hours remaining: ".(($datetime-$date2)/3600). "<br>";
$holdtothr=(($datetime-$date2)/3600);
//
//Days - a day is a 24 hour period
//This gives days remaining
$holdtotday=intval(($datetime-$date2)/86400);
echo "total days remaining: ".$holdtotday. "<br>";
//
//Find hours remaining - get days in hours and sub from tothr
$holdhr=intval($holdtothr-($holdtotday*24));
echo "hours remaining: ".($holdhr). "<br>";
//
//Find minutes remaining - get days and hours in minutes and sub from totmin
$holdmr=intval($holdtotmin-(($holdhr*60)+($holdtotday*1440)));
echo "minutes remaining: ".($holdmr). "<br>";
//
//Find seconds remaining - get days hours minutes in seconds and sub from totsec
$holdsr=intval($holdtotsec-(($holdhr*3600)+($holdmr*60)+(86400*$holdtotday)));
echo "seconds remaining: ".($holdsr). "<br>";
}
?>