#46993 [Asn->Bgs]: strtotime inconsistently parses M-j-Y and Y-M-j format dates
| From: | derick@php.net | Date: | Wed, 29 Jul 2009 17:52:55 +0000 |
| Subject: | #46993 [Asn->Bgs]: strtotime inconsistently parses M-j-Y and Y-M-j format dates | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-140449@lists.php.net to get a copy of this message | ||
ID: 46993
Updated by: derick@php.net
Reported By: anomie at users dot sourceforge dot net
-Status: Assigned
+Status: Bogus
Bug Type: Date/time related
Operating System: Linux
PHP Version: 5.*, 6CVS (2009-01-02)
Assigned To: derick
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
THis is how the parser works, we can't anticipate *all* forms and
changing this breaks other things.
Previous Comments:
------------------------------------------------------------------------
[2009-01-02 16:24:10] anomie at users dot sourceforge dot net
Description:
------------
M-j-Y format dates are parsed correctly if the day is 10-31, but as
M-j-Hi if the day is 1-9. Or, you could say that M-j-Hi format dates are
parsed correctly if the day is 1-9, but incorrectly if the day is
10-31.
Y-M-j format dates are parsed correctly if the day is 10-31, but as Y-M
in the timezone UTC-j if the day is 1-9. Or, you could say that this odd
method of specifying the time zone fails for UTC-10, UTC-11, and so on.
Both M-d-Y and Y-M-d formats are parsed correctly for all days.
I would find it more consistent if the M-j-Y and Y-M-j formats were
recognized for all days, as the other option would conflict with M-d-Y
and Y-M-d recognition and both "M-j-Hi" and "Y-M"-with-timezone seem to
be unlikely input formats.
This bug is also present in PHP 5.2.6.
Reproduce code:
---------------
date_default_timezone_set("UTC");
echo date("Y-m-d H:i:s\n", strtotime("Dec-9-2006"));
echo date("Y-m-d H:i:s\n", strtotime("9-Dec-2006"));
echo date("Y-m-d H:i:s\n", strtotime("2006-Dec-9"));
echo date("Y-m-d H:i:s\n", strtotime("Dec-10-2006"));
echo date("Y-m-d H:i:s\n", strtotime("10-Dec-2006"));
echo date("Y-m-d H:i:s\n", strtotime("2006-Dec-10"));
Expected result:
----------------
2006-12-09 00:00:00
2006-12-09 00:00:00
2006-12-09 00:00:00
2006-12-10 00:00:00
2006-12-10 00:00:00
2006-12-10 00:00:00
Actual result:
--------------
2009-12-09 20:06:00
2006-12-09 00:00:00
2006-12-01 09:00:00
2006-12-10 00:00:00
2006-12-10 00:00:00
2006-12-10 00:00:00
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46993&edit=1