Bug #80141 [Opn->Dup]: Datetime::createFromFormat('c') fails with c formatted string
| From: | salathe@php.net | Date: | Wed, 23 Sep 2020 08:36:11 +0000 |
| Subject: | Bug #80141 [Opn->Dup]: Datetime::createFromFormat('c') fails with c formatted string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-229166@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80141&edit=1
ID: 80141
Updated by: salathe@php.net
Reported by: kylekatarnls at gmail dot com
Summary: Datetime::createFromFormat('c') fails with c
formatted string
-Status: Open
+Status: Duplicate
Type: Bug
Package: Date/time related
PHP Version: 7.4.10
Block user comment: N
Private report: N
New Comment:
Duplicate of #72592.
Previous Comments:
------------------------------------------------------------------------
[2020-09-23 08:26:35] cmb@php.net
According to the docs, ::createFromFormat() does not support the
'c' format. Use DateTimeInterface::ATOM instead:
<https://3v4l.org/jf52r>.
------------------------------------------------------------------------
[2020-09-23 08:05:50] kylekatarnls at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=80141&edit=1