Bug #80057 [Opn->Csd]: DateTimeImmutable::createFromFormat() does not populate time

From: Date: Fri, 04 Sep 2020 14:55:27 +0000
Subject: Bug #80057 [Opn->Csd]: DateTimeImmutable::createFromFormat() does not populate time
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228888@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80057&edit=1 ID: 80057 Updated by: derick@php.net Reported by: bc at benjamin-cremer dot de Summary: DateTimeImmutable::createFromFormat() does not populate time -Status: Open +Status: Closed Type: Bug Package: Date/time related Operating System: linux PHP Version: 8.0.0beta3 Block user comment: N Private report: N New Comment: Automatic comment on behalf of github@derickrethans.nl Revision: http://git.php.net/?p=php-src.git;a=commit;h=2ee2335249d4bbeed27d60a59245a966d0580074 Log: Fixed bug #80057 (DateTimeImmutable::createFromFormat() does not populate time) Previous Comments: ------------------------------------------------------------------------ [2020-09-04 10:16:57] bc at benjamin-cremer dot de Description: ------------ The current time is not populated when a DateTime object is created by createFromFormat with a format pattern that has no time part defined. Given the following code: var_dump(DateTimeImmutable::createFromFormat('Y-m-d', '2020-09-04')); Output from 8.0.0beta2 and before: object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2020-09-04 10:28:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Output from 8.0.0beta3: object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2020-09-04 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Test script: --------------- <?php var_dump(DateTimeImmutable::createFromFormat('Y-m-d', '2020-09-04')->format('His') > 0); Expected result: ---------------- bool(true) Actual result: -------------- bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80057&edit=1

« previous php.bugs (#228888) next »