From: anomie at users dot sourceforge dot net
Operating system: Linux
PHP version: 5.3CVS-2009-01-02 (snap)
PHP Bug Type: Date/time related
Bug description: strtotime inconsistently parses M-j-Y and Y-M-j format dates
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 bug report at http://bugs.php.net/?id=46993&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46993&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46993&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46993&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=46993&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=46993&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=46993&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=46993&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=46993&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=46993&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=46993&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=46993&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46993&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46993&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=46993&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46993&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46993&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=46993&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=46993&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=46993&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=46993&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=46993&r=mysqlcfg