Bug #79685 [NEW]: createFromFormat doesn't work with option G

From: Date: Wed, 10 Jun 2020 09:02:46 +0000
Subject: Bug #79685 [NEW]: createFromFormat doesn't work with option G
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227393@lists.php.net to get a copy of this message
From:             contact at eslistavenga dot nl
Operating system: Linux
PHP version:      7.4.6
Package:          Date/time related
Bug Type:         Bug
Bug description:createFromFormat doesn't work with option G

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

-- 
Edit bug report at https://bugs.php.net/bug.php?id=79685&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79685&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79685&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79685&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79685&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79685&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79685&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79685&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79685&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79685&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79685&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79685&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79685&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79685&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79685&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79685&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79685&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79685&r=mysqlcfg


Thread (1 message)

  • contact at eslistavenga dot nl
« previous php.bugs (#227393) next »