note 40063 added to ref.datetime
| From: | scott_webster_2000 at yahoo dot com | Date: | Fri, 20 Feb 2004 15:02:21 +0000 |
| Subject: | note 40063 added to ref.datetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65446@lists.php.net to get a copy of this message | ||
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;
}
----
Manual Page -- http://www.php.net/manual/en/ref.datetime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40063
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40063&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40063&report=yes
Search -- http://master.php.net/manage/user-notes.php