Bug #80141 [NEW]: Datetime::createFromFormat('c') fails with c formatted string
From: kylekatarnls at gmail dot com
Operating system:
PHP version: 7.4.10
Package: Date/time related
Bug Type: Bug
Bug description:Datetime::createFromFormat('c') fails with c formatted string
Description:
------------
This bug relates to https://bugs.php.net/bug.php?id=72592 which has
been
closed as duplicated while it's different from the bug it's supposed to
duplicate (64414).
Datetime::createFromFormat() return false and generates 2 errors in
getLastErrors() when giving the format 'c' and a string that has
actually be output with format('c').
Side note: it works fine when passing the format 'Y-m-d\TH:i:sP' to
createFromFormat()
Test script:
---------------
var_dump(DateTime::createFromFormat('c', (new
DateTime('2020-02-02'))->format('c')));
echo implode("\n", DateTime::getLastErrors()['errors']);
Expected result:
----------------
object(DateTime)#3 (3) {
["date"]=>
string(26) "2020-02-02 00:00:00.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
Actual result:
--------------
false
The format separator does not match
Trailing data
--
Edit bug report at https://bugs.php.net/bug.php?id=80141&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80141&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80141&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80141&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80141&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80141&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80141&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80141&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80141&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80141&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80141&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80141&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80141&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80141&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80141&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80141&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80141&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80141&r=mysqlcfg
Thread (3 messages)
- kylekatarnls at gmail dot com