Bug #72592 [NEW]: Datetime::createFromFormat not working with ISO 8601 modifier 'c'
From: houweling dot frank at gmail dot com
Operating system: All
PHP version: Irrelevant
Package: Unknown/Other Function
Bug Type: Bug
Bug description:Datetime::createFromFormat not working with ISO 8601 modifier 'c'
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 bug report at https://bugs.php.net/bug.php?id=72592&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72592&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72592&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72592&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72592&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72592&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72592&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72592&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72592&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72592&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72592&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72592&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72592&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72592&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72592&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72592&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72592&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72592&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72592&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72592&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72592&r=mysqlcfg
Thread (5 messages)
- houweling dot frank at gmail dot com