|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-06-10 11:21 UTC] requinix@php.net
-Summary: createFromFormat doesn't work with option G
+Summary: createFromFormat doesn't work easily with unpadded
components
-Type: Bug
+Type: Documentation Problem
[2020-06-10 11:21 UTC] requinix@php.net
[2021-12-27 07:51 UTC] requinix@php.net
-Status: Open
+Status: Duplicate
[2021-12-27 07:51 UTC] requinix@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 14:00:02 2025 UTC |
Description: ------------ When using the DateTime format ymdGis without any formatting, like hour/minute/second separator, the method will throw an error. See code example below. The method expects a leading 0, even tho the hour format 'G' was used and not 'H' Test script: --------------- <?php //won't work $date = DateTime::createFromFormat('ymdGis', '20061071018'); var_dump($date); //false var_dump(DateTime::getLastErrors()); //will work $date = DateTime::createFromFormat('ymdG-is', '2006107-1018'); var_dump($date); //DateTime::object var_dump(DateTime::getLastErrors()); Expected result: ---------------- A valid DateTime object Actual result: -------------- false