note 102017 added to function.time

From: Date: Sun, 23 Jan 2011 11:44:57 +0000
Subject: note 102017 added to function.time
Groups: php.notes 
Request: Send a blank email to php-notes+get-176021@lists.php.net to get a copy of this message
To accurately calculate the difference between the current time and a time in the future I use the following. <?php function time_difference($endtime){ $days= (date("j",$endtime)-1); $months =(date("n",$endtime)-1); $years =(date("Y",$endtime)-1970); $hours =date("G",$endtime); $mins =date("i",$endtime); $secs =date("s",$endtime); $diff="'day': ".$days.",'month': ".$months.",'year': ".$years.",'hour': ".$hours.",'min': ".$mins.",'sec': ".$secs; return $diff; } $end_time = $future_date - time(); $difference = time_difference($end_time); echo $difference; //sample output 'day': 2,'month': 1,'year': 0,'hour': 2,'min': 05,'sec': 41 ?> ---- Server IP: 69.147.83.197 Probable Submitter: 80.229.162.206 ---- Manual Page -- http://www.php.net/manual/en/function.time.php Edit -- https://master.php.net/note/edit/102017 Del: integrated -- https://master.php.net/note/delete/102017/integrated Del: useless -- https://master.php.net/note/delete/102017/useless Del: bad code -- https://master.php.net/note/delete/102017/bad+code Del: spam -- https://master.php.net/note/delete/102017/spam Del: non-english -- https://master.php.net/note/delete/102017/non-english Del: in docs -- https://master.php.net/note/delete/102017/in+docs Del: other reasons-- https://master.php.net/note/delete/102017 Reject -- https://master.php.net/note/reject/102017 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#176021) next »