Bug #78778 [Opn->Ver]: DateTime constructor and createFromFormat behaves differently

From: Date: Mon, 04 Nov 2019 11:57:03 +0000
Subject: Bug #78778 [Opn->Ver]: DateTime constructor and createFromFormat behaves differently
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223562@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78778&edit=1 ID: 78778 Updated by: cmb@php.net Reported by: boan at jfmedier dot dk Summary: DateTime constructor and createFromFormat behaves differently -Status: Open +Status: Verified Type: Bug Package: Date/time related PHP Version: 7.2.24 Block user comment: N Private report: N New Comment: Well, that doesn't look quite right: <https://3v4l.org/AADtE>. Previous Comments: ------------------------------------------------------------------------ [2019-11-04 11:45:38] boan at jfmedier dot dk Description: ------------ I would expect that the factory method createFromFormat should work like the constructor parameter. Test script: --------------- $date = new DateTimeImmutable('2019-11-01T12:12:40.8859136+00:00'); var_dump($date); $date = DateTimeImmutable::createFromFormat(DateTimeInterface::RFC3339_EXTENDED, '2019-11-01T12:12:40.8859136+00:00'); var_dump($date); Expected result: ---------------- object(DateTimeImmutable) { ["date"]=> string(26) "2019-11-01 12:12:40.885913" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } object(DateTimeImmutable) { ["date"]=> string(26) "2019-11-01 12:12:40.885913" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } Actual result: -------------- object(DateTimeImmutable) { ["date"]=> string(26) "2019-11-01 12:12:40.885913" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78778&edit=1

« previous php.bugs (#223562) next »