Bug #53539 [Opn]: strtotime off-by-1-week bug still not fixed
| From: | derick@php.net | Date: | Mon, 13 Dec 2010 16:29:48 +0000 |
| Subject: | Bug #53539 [Opn]: strtotime off-by-1-week bug still not fixed | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5676@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53539&edit=1
ID: 53539
Updated by: derick@php.net
Reported by: kugel at rci dot rutgers dot edu
Summary: strtotime off-by-1-week bug still not fixed
Status: Open
Type: Bug
-Package: *General Issues
+Package: Documentation problem
Operating System: Fedora
PHP Version: 5.3SVN-2010-12-13 (SVN)
Block user comment: N
Private report: N
New Comment:
This is not a *code* bug though.
It works like follows:
"January 2011 8:00pm" is an absolute date string, which processed
first:
$ php -r 'echo date("Y-m-d H:i:s", strtotime("January 2011 8:00pm"));'
2011-01-01 20:00:00
$ php -r 'echo strtotime("January 2011 8:00pm");'
1293912000
"first Saturday" is a string relative to the absolute date string, which
is processed next:
$ php -r 'echo date("Y-m-d H:i:s", strtotime("first Saturday",
1293912000));'
2011-01-08 00:00:00
You are missing the "of" keyword, which links the two together:
$ php -r 'echo date("Y-m-d H:i:s", strtotime("first Saturday of January
2011 8:00pm")), "\n";'
2011-01-01 20:00:00
$ php -r 'echo date("Y-m-d H:i:s", strtotime("third Saturday of January
2011 8:00pm")), "\n";'
2011-01-15 20:00:00
Previous Comments:
------------------------------------------------------------------------
[2010-12-13 17:01:37] kugel at rci dot rutgers dot edu
better bug title
------------------------------------------------------------------------
[2010-12-13 16:59:43] kugel at rci dot rutgers dot edu
Description:
------------
---
From manual page: http://www.php.net/function.strtotime#Changelog
---
"5.2.7 In PHP 5 prior to 5.2.7, requesting a given occurrence of a given
weekday in a month where that weekday was the first day of the month
would incorrectly add one week to the returned timestamp. This has been
corrected in 5.2.7 and later versions."
Contrary to the above, this bug still exists in PHP 5.2.13, 5.2.14, and
5.3.3.
Test script:
---------------
<?php
date_default_timezone_set("America/New_York");
echo date("D, M j Y", strtotime("first Saturday January 2011 8:00pm")) .
"\n";
echo date("D, M j Y", strtotime("third Saturday January 2011 8:00pm")) .
"\n";
?>
Expected result:
----------------
Sat, Jan 1 2011
Sat, Jan 15 2011
Actual result:
--------------
Sat, Jan 8 2011
Sat, Jan 22 2011
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53539&edit=1