Req #71407 [NEW]: Accept one digit minutes and seconds in date_create_from_format() function

From: Date: Mon, 18 Jan 2016 15:07:18 +0000
Subject: Req #71407 [NEW]: Accept one digit minutes and seconds in date_create_from_format() function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198759@lists.php.net to get a copy of this message
From: hamid dot a85 at gmail dot com Operating system: PHP version: 5.6.17 Package: Date/time related Bug Type: Feature/Change Request Bug description:Accept one digit minutes and seconds in date_create_from_format() function Description: ------------ Currently, there is no way for date_create_from_format() to accept one digit seconds/minutes. But they do accept one digit hours, month, and years: date_create_from_format('Y-m-d H:i:s', '2016-1-2 3:04:05'); will output a DateTime object, but the following code will return false: date_create_from_format('Y-m-d H:i:s', '2016-1-2 3:4:5'); Although backward compatibility may be an issue, I guess it would be nice if one digit seconds and minutes like '4:5' be accepted by date_create_from_format() and date_parse_from_format(). Test script: --------------- var_export(date_create_from_format('Y-m-d H:i:s', '2016-1-2 3:4:5')); var_export(date_parse_from_format('Y-m-d H:i:s', '2016-1-2 3:4:5')); Expected result: ---------------- DateTime::__set_state(array( 'date' => '2016-01-02 03:04:05', 'timezone_type' => 3, 'timezone' => 'Asia/Tehran', )) array ( 'year' => 2016, 'month' => 1, 'day' => 2, 'hour' => 3, 'minute' => 4, 'second' => 5, 'fraction' => false, 'warning_count' => 0, 'warnings' => array ( ), 'error_count' => 0, 'errors' => array ( ), 'is_localtime' => false, ) Actual result: -------------- false array ( 'year' => 2016, 'month' => 1, 'day' => 2, 'hour' => 3, 'minute' => 0, 'second' => 0, 'fraction' => false, 'warning_count' => 0, 'warnings' => array ( ), 'error_count' => 2, 'errors' => array ( 11 => 'A two digit minute could not be found', 13 => 'A two digit second could not be found', ), 'is_localtime' => false, ) -- Edit bug report at https://bugs.php.net/bug.php?id=71407&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71407&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71407&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71407&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71407&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71407&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71407&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71407&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71407&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71407&r=support Expected behavior: https://bugs.php.net/fix.php?id=71407&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71407&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71407&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71407&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71407&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71407&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71407&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71407&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71407&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71407&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71407&r=mysqlcfg

« previous php.bugs (#198759) next »