note 101971 deleted from function.date-diff by danbrown
| From: | danbrown@php.net | Date: | Thu, 20 Jan 2011 20:05:46 +0000 |
| Subject: | note 101971 deleted from function.date-diff by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175950@lists.php.net to get a copy of this message | ||
Note Submitter: joe at golike dot com
----
I use this much simpler solution:
function dateDifference($firstDate, $lastDate) {
$firstTime = strtotime($firstDate);
$lastTime = strtotime($lastDate);
$diff = round(($lastTime - $firstTime) / 86400);
return $diff;
}
I've tested this using all of the cases I could think of:
- dates inside DST
- dates outside DST
- dates overlapping the start of DST
- dates overlapping the end of DST
- dates during a leap year
- dates during a non-leap year
Am I missing something that the other more complicated solutions are accounting for?