Bug #75577 [NEW]: DateTime::createFromFormat does not accept RFC3339_EXTENDED format

From: Date: Mon, 27 Nov 2017 03:57:34 +0000
Subject: Bug #75577 [NEW]: DateTime::createFromFormat does not accept RFC3339_EXTENDED format
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212733@lists.php.net to get a copy of this message
From: php-bugs at dennis dot birkholz dot biz Operating system: Linux PHP version: 7.2.0RC6 Package: Date/time related Bug Type: Bug Bug description:DateTime::createFromFormat does not accept RFC3339_EXTENDED format Description: ------------ DateTime::createFromFormat(), DateTimeImmutable::createFromFormat() and date_create_from_format() fail to create a DateTime(Immutable) object when the format is RFC3339_EXTENDED and a valid date string is supplied but using the constructors / date_create() works. See https://3v4l.org/shJD7 Test script: --------------- <?php $datestring = '2017-06-03T00:08:10.881UTC'; if ($date = DateTime::createFromFormat(DateTime::RFC3339_EXTENDED, $datestring)) { print_r($date); } else { print_r(DateTime::getLastErrors()); } if ($date = new DateTime($datestring)) { print_r($date); } else { print_r(DateTime::getLastErrors()); } Expected result: ---------------- DateTime Object ( [date] => 2017-06-03 00:08:10.881000 [timezone_type] => 3 [timezone] => UTC ) DateTime Object ( [date] => 2017-06-03 00:08:10.881000 [timezone_type] => 3 [timezone] => UTC ) Actual result: -------------- Array ( [warning_count] => 0 [warnings] => Array ( ) [error_count] => 2 [errors] => Array ( [20] => The format separator does not match [21] => The timezone could not be found in the database ) ) DateTime Object ( [date] => 2017-06-03 00:08:10.881000 [timezone_type] => 3 [timezone] => UTC ) -- Edit bug report at https://bugs.php.net/bug.php?id=75577&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75577&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75577&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75577&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75577&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75577&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75577&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75577&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75577&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75577&r=support Expected behavior: https://bugs.php.net/fix.php?id=75577&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75577&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75577&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75577&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75577&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75577&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75577&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75577&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75577&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75577&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75577&r=mysqlcfg

« previous php.bugs (#212733) next »