Edit report at http://bugs.php.net/bug.php?id=54316&edit=1
ID: 54316 Updated by: ahar...@php.net Reported by: gtisza at gmail dot com Summary: DateTime::createFromFormat does not handle trailing '|' correctly -Status: Verified +Status: Assigned Type: Bug Package: Date/time related Operating System: Windows XP, Debian 2.6 PHP Version: 5.3.6 -Assigned To: +Assigned To: aharvey Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2011-03-21 06:03:15] ahar...@php.net Confirmed on a current 5.3 SVN build. ------------------------------------------------------------------------ [2011-03-19 12:34:54] gtisza at gmail dot com 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 this bug report at http://bugs.php.net/bug.php?id=54316&edit=1