Bug #53417 [NEW]: strtotime does not handle MySQL Fuzzy Dates Correctly

From: Date: Fri, 26 Nov 2010 15:03:26 +0000
Subject: Bug #53417 [NEW]: strtotime does not handle MySQL Fuzzy Dates Correctly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-156493@lists.php.net to get a copy of this message
From: Operating system: Redhat PHP version: 5.3.1RC1 Package: Date/time related Bug Type: Bug Bug description:strtotime does not handle MySQL Fuzzy Dates Correctly Description: ------------ The function strtotime doesn't handle MySQL fuzzy dates correctly, in MySQL it is possible to store fuzzy dates replacing the unknown date figure with 00, for example. 2010-10-00 00:00:00 which is UK format Y-m-d If you pass this script to strtotime and wrap the date function around it: date('M y', (strtotime($monrow['eventdate']))); PHP will return Oct 10, which is a month out as it should return Nov 10. Workaround is to use str_replace to change the 00 to 01 when processing. Test script: --------------- date('M y', (strtotime("2010-10-00 00:00:00"))); Expected result: ---------------- Nov 10 (Month as specified) Actual result: -------------- Oct 10 (Previous Month) -- Edit bug report at http://bugs.php.net/bug.php?id=53417&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53417&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53417&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53417&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53417&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53417&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53417&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53417&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53417&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53417&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53417&r=support Expected behavior: http://bugs.php.net/fix.php?id=53417&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53417&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53417&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53417&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53417&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53417&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53417&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53417&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53417&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53417&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53417&r=mysqlcfg

« previous php.bugs (#156493) next »