Bug->Req #72592 [Csd->ReO]: Datetime::createFromFormat not working with ISO 8601 modifier 'c'
Edit report at https://bugs.php.net/bug.php?id=72592&edit=1
ID: 72592
Updated by: salathe@php.net
Reported by: houweling dot frank at gmail dot com
Summary: Datetime::createFromFormat not working with ISO 8601
modifier 'c'
-Status: Closed
+Status: Re-Opened
-Type: Bug
+Type: Feature/Change Request
-Package: Unknown/Other Function
+Package: Date/time related
Operating System: All
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Re-opened as this is a new feature request: to add support for the 'c' format, which is
not currently one of the supported formats for DateTime::createFromFormat()[1].
[1] https://www.php.net/manual/en/datetime.createfromformat.php
Previous Comments:
------------------------------------------------------------------------
[2020-09-23 07:21:31] kylekatarnls at gmail dot com
Hello, this is not a duplicate of 51950, this last one is about decimal fractions, while
c format does not output decimal and still fails in createFromFormat. Could you re-open
please?
------------------------------------------------------------------------
[2016-07-13 11:26:54] houweling dot frank at gmail dot com
Duplicate of https://bugs.php.net/bug.php?id=51950
------------------------------------------------------------------------
[2016-07-13 11:19:39] houweling dot frank at gmail dot com
Description:
------------
I have tested this bug on Windows / Linux and PHP versions 5.5 and 7.0. The
DateTime::createFromFormat function does not correctly use the ISO 8601 modifier ('c').
Trying to parse an ISO 8601 datetime string using this function results in 'false'.
Test script:
---------------
<?php
// Create datetime
$date = new \DateTime('now');
var_dump($date); // = DateTime Object
// Convert to string
$fDate = $date->format('c');
var_dump($fDate); // = ISO 8601 string
// Read data to object
$rDate = \DateTime::createFromFormat('c', $fDate);
var_dump($rDate); // = false
Expected result:
----------------
\DateTime::createFromFormat('c', $fDate); should result in a valid DateTime object, with
the same contents as the original $date object.
Actual result:
--------------
False, the createFromFormat function cannot parse the string
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72592&edit=1
Thread (5 messages)