note 40063 rejected from ref.datetime by danbrown

From: Date: Sun, 20 Jul 2008 02:25:59 +0000
Subject: note 40063 rejected from ref.datetime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141958@lists.php.net to get a copy of this message
Note Submitter: scott_webster_2000 at yahoo dot com ---- Here is a slight improvement over wwb_99@yahoo's entry. (It works now.) function date_diff($earlierDate, $laterDate) { //returns an array of numeric values representing days, hours, minutes & seconds respectively $ret=array('days'=>0,'hours'=>0,'minutes'=>0,'seconds'=>0); $totalsec = $laterDate - $earlierDate; if ($totalsec >= 86400) { $ret['days'] = floor($totalsec/86400); $totalsec = $totalsec % 86400; } if ($totalsec >= 3600) { $ret['hours'] = floor($totalsec/3600); $totalsec = $totalsec % 3600; } if ($totalsec >= 60) { $ret['minutes'] = floor($totalsec/60); } $ret['seconds'] = $totalsec % 60; return $ret; }

« previous php.notes (#141958) next »