Bug #72592 [Com]: Datetime::createFromFormat not working with ISO 8601 modifier 'c'

From: Date: Wed, 23 Sep 2020 07:21:31 +0000
Subject: Bug #72592 [Com]: Datetime::createFromFormat not working with ISO 8601 modifier 'c'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229161@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72592&edit=1

 ID:                 72592
 Comment by:         kylekatarnls at gmail dot com
 Reported by:        houweling dot frank at gmail dot com
 Summary:            Datetime::createFromFormat not working with ISO 8601
                     modifier 'c'
 Status:             Closed
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   All
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

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?


Previous Comments:
------------------------------------------------------------------------
[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)

« previous php.bugs (#229161) next »