From: tagadvance at gmail dot com Operating system: Linux PHP version: Irrelevant Package: Date/time related Bug Type: Bug Bug description:DateTime::createFromFormat() incorrectly parses illogical dates
Description: ------------ --- >From manual page: http://www.php.net/datetime.createfromformat --- The DateTime::createFromFormat() method incorrectly parses an illogical date. I have tested this on version 5.3.3 (CentOS) and 5.4.6 (Ubuntu). Test script: --------------- <?php // November 16 falls on a Friday, NOT a Wednesday $date = 'Wednesday 16 November 2012'; $format = 'l d M Y'; try { $dateTime = DateTime::createFromFormat($format, $date); $formattedDateTime = $dateTime->format($format); echo $formattedDateTime . PHP_EOL; // prints "Wednesday 21 Nov 2012" } catch (Exception $e) { // no exception is thrown =( echo $e->getMessage(); } ?> Expected result: ---------------- I expect the createFromFormat method to throw an error if the date is illogical. At the very least a warning should be added to the log. Actual result: -------------- The createFromFormat parses the illogical date. The day seems to take precedence over the date. I am just guessing here, but it then seems to round up by one week so that the date makes sense. -- Edit bug report at https://bugs.php.net/bug.php?id=64040&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64040&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64040&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64040&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64040&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64040&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64040&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64040&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64040&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64040&r=support Expected behavior: https://bugs.php.net/fix.php?id=64040&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64040&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64040&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64040&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64040&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64040&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64040&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64040&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64040&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64040&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64040&r=mysqlcfg