|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 12:00:01 2025 UTC |
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 -0400strtotime("May 1st third Monday") returns false in the latest CVS and I think the result is correct, since the date is invalid.