Req #72592 [ReO->Wfx]: Datetime::createFromFormat not working with ISO 8601 modifier 'c'

From: Date: Sun, 05 Jun 2022 13:48:43 +0000
Subject: Req #72592 [ReO->Wfx]: Datetime::createFromFormat not working with ISO 8601 modifier 'c'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241669@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 Updated by: derick@php.net Reported by: houweling dot frank at gmail dot com Summary: Datetime::createFromFormat not working with ISO 8601 modifier 'c' -Status: Re-Opened +Status: Wont fix Type: Feature/Change Request Package: Date/time related Operating System: All PHP Version: Irrelevant Block user comment: N Private report: N New Comment: I am marking this as "won't fix", because you can instead parse this string by using the DateTime constructor instead. If you are still interested in having this feature, please file a new issue at https://github.com/php/php-src/issues/ with a well defined and explained use case. Previous Comments: ------------------------------------------------------------------------ [2020-09-23 08:35:35] salathe@php.net 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#241669) next »