note 102017 deleted from function.time by cmb

From: Date: Sun, 01 Aug 2021 14:57:39 +0000
Subject: note 102017 deleted from function.time by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-216712@lists.php.net to get a copy of this message
Note Submitter: karls_post at hotmail dot com ---- 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 ?>

« previous php.notes (#216712) next »