|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-09-23 13:35 UTC] cmb@php.net
[2022-06-05 13:42 UTC] derick@php.net
-Status: Open
+Status: Wont fix
[2022-06-05 13:42 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 12:00:01 2025 UTC |
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, )