Incorrect timestamp returned for strtotime()
| Bug #37368 | Incorrect timestamp returned for strtotime() | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2006-05-08 17:16 UTC | Modified: | 2006-08-01 22:19 UTC |
|
||||||||||
| From: | ramsey@php.net | Assigned: | derick (profile) | |||||||||||
| Status: | Closed | Package: | Date/time related | |||||||||||
| PHP Version: | 5.1.4 | OS: | Debian sarge | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2006-05-08 17:16 UTC] ramsey@php.net
Description:
------------
When using strtotime() in PHP 5.1.4, it returns an inaccurate timestamp, but PHP 5.0.4 and 4.4.2 return the correct timestamp.
Reproduce code:
---------------
php -r 'echo date("r", strtotime("Mon, 08 May 2006 13:06:44 -0400 +30 days"));'
Expected result:
----------------
Wed, 07 Jun 2006 13:06:44 -0400
Actual result:
--------------
Mon, 12 Jun 2006 13:06:44 -0400
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2006-05-14 17:35 UTC] derick@php.net
[2006-05-24 21:34 UTC] ramsey@php.net
I'm not sure whether this is related, but I found a new issue with strtotime(). It looks like the words "second" and "third" are not working correctly. Reproduce code: echo date('r', strtotime('May 1st first Monday')) . "\n"; echo date('r', strtotime('May 1st second Monday')) . "\n"; echo date('r', strtotime('May 1st third Monday')) . "\n"; echo date('r', strtotime('May 1st fourth Monday')) . "\n"; echo date('r', strtotime('May 1st fifth Monday')) . "\n"; I expect the output to be: Mon, 08 May 2006 00:00:00 -0400 Wed, 15 May 2006 00:00:00 -0400 Wed, 22 May 2006 00:00:00 -0400 Mon, 29 May 2006 00:00:00 -0400 Mon, 05 Jun 2006 00:00:00 -0400 but the actual output (with PHP 5.1.4) is: Mon, 08 May 2006 00:00:00 -0400 Wed, 31 Dec 1969 19:00:00 -0500 Wed, 31 Dec 1969 19:00:00 -0500 Mon, 29 May 2006 00:00:00 -0400 Mon, 05 Jun 2006 00:00:00 -0400 With PHP 4.4.2, the actual output is: Tue, 01 May 2001 00:00:00 -0400 Mon, 01 May 2006 00:00:01 -0400 Thu, 01 May 2003 00:00:00 -0400 Sat, 01 May 2004 00:00:00 -0400 Sun, 01 May 2005 00:00:00 -0400[2006-05-24 21:41 UTC] ramsey@php.net
[2006-08-01 22:19 UTC] tony2001@php.net
strtotime("May 1st third Monday") returns false in the latest CVS and I think the result is correct, since the date is invalid.