note 80253 added to ref.datetime
| From: | DaveLaurier at osu1 dot php dot net | Date: | Sun, 06 Jan 2008 14:42:41 +0000 |
| Subject: | note 80253 added to ref.datetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-134894@lists.php.net to get a copy of this message | ||
I really like the date_diff function from stoicnluv because of its capabilities to handle leap years
and daylight saving time but I found out is is not working correctly when there is more than 1 year
and 2 months between the two dates. For example:
d1 = 2006-10-28
d2 = 2007-11-30
The result for months and days is correct (one year, one month and two days):
Array
(
[years] => 1
[months] => 1
[days] => 2
[hours] => 1
[minutes] => 0
[seconds] => 0
[months_total] => 12
[days_total] => 398
[hours_total] => 9553
[minutes_total] => 573180
[seconds_total] => 34390800
)
However when using a date which is +1 year +2 months:
d1 = 2006-10-28
d2 = 2007-12-01
The result is incorrect (expected: one year, two months and 1 day, returns one year, one month and 3
days):
Array
(
[years] => 1
[months] => 1
[days] => 3
[hours] => 1
[minutes] => 0
[seconds] => 0
[months_total] => 12
[days_total] => 399
[hours_total] => 9577
[minutes_total] => 574620
[seconds_total] => 34477200
)
----
Server IP: 83.137.20.135
Probable Submitter: 77.249.204.67
----
Manual Page -- http://www.php.net/manual/en/ref.datetime.php
Edit -- https://master.php.net/note/edit/80253
Del: integrated -- https://master.php.net/note/delete/80253/integrated
Del: useless -- https://master.php.net/note/delete/80253/useless
Del: bad code -- https://master.php.net/note/delete/80253/bad+code
Del: spam -- https://master.php.net/note/delete/80253/spam
Del: non-english -- https://master.php.net/note/delete/80253/non-english
Del: in docs -- https://master.php.net/note/delete/80253/in+docs
Del: other reasons-- https://master.php.net/note/delete/80253
Reject -- https://master.php.net/note/reject/80253
Search -- https://master.php.net/manage/user-notes.php