From: Operating system: Windows XP, Debian 2.6 PHP version: 5.3.6 Package: Date/time related Bug Type: Bug Bug description:DateTime::createFromFormat does not handle trailing '|' correctly
Description: ------------ --- >From manual page: http://www.php.net/datetime.createfromformat --- According to the documentation: """ | - Resets all fields (year, month, day, hour, minute, second, fraction and timzone information) to the Unix Epoch if they have not been parsed yet Y-m-d| will set the year, month and day to the information found in the string to parse, and sets the hour, minute and second to 0. """ Actually, it fails to parse the date (but works correctly when | is not at the end of the string). Tested on PHP 5.3.2/Win XP and PHP 5.3.5/Debian. Can't test on 5.3.6 right now as windows.php.net seems unavailable. Test script: --------------- var_dump(DateTime::createFromFormat('Y-m-d|', '2011-02-02')); $errors = DateTime::getLastErrors(); var_dump($errors['errors']); Expected result: ---------------- object(DateTime)#1 (3) { ["date"]=> string(19) "2011-02-02 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(15) "Europe/Budapest" } array(0) { } Actual result: -------------- bool(false) array(1) { [10]=> string(12) "Data missing" } -- Edit bug report at http://bugs.php.net/bug.php?id=54316&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54316&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54316&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54316&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54316&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54316&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54316&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54316&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54316&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54316&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54316&r=support Expected behavior: http://bugs.php.net/fix.php?id=54316&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54316&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54316&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54316&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54316&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54316&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54316&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54316&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54316&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54316&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54316&r=mysqlcfg