Re: PHP timer

From: Date: Fri, 22 Jun 2001 04:44:53 +0000
Subject: Re: PHP timer
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-54831@lists.php.net to get a copy of this message
On Fri, 22 Jun 2001 06:41, george wrote: > My back is aganist the wall with this one, I have to create a timer . > > What happens is admin will enter a time say 2 hours in the future > this time will be stored in a db as a time stamp > then the current time and the timestamp from the db are subtracted from > one another and the result is shown as hours minutes and seconds. > but I cant get it to work at all > any suggestions would be great > > > TIA > George This might be the direction you want? <?php $now = time(); //Get current timestamp $then = mktime(0,0,0,7,12,2001); $diff = $then - $now; $ary = getdate($diff); while(list($key, $val) = each($ary)){ echo "$key ==> $val<BR>"; } ?> Outputs seconds ==> 46 minutes ==> 16 hours ==> 19 mday ==> 20 wday ==> 2 mon ==> 1 year ==> 1970 yday ==> 19 weekday ==> Tuesday month ==> January 0 ==> 1676806 -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA "I prefer unlined gloves," Tom deferred.

« previous php.general (#54831) next »