Bug #72592 [Opn->Csd]: Datetime::createFromFormat not working with ISO 8601 modifier 'c'
| From: | houweling dot frank at gmail dot com | Date: | Wed, 13 Jul 2016 11:26:54 +0000 |
| Subject: | Bug #72592 [Opn->Csd]: Datetime::createFromFormat not working with ISO 8601 modifier 'c' | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202274@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
User updated by: houweling dot frank at gmail dot com
Reported by: houweling dot frank at gmail dot com
Summary: Datetime::createFromFormat not working with ISO 8601
modifier 'c'
-Status: Open
+Status: Closed
Type: Bug
Package: Unknown/Other Function
Operating System: All
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Duplicate of https://bugs.php.net/bug.php?id=51950
Previous Comments:
------------------------------------------------------------------------
[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