Bug #77701 [Opn->Ver]: \DateTime::createFromFormat does not set default parts

From: Date: Wed, 06 Mar 2019 04:23:34 +0000
Subject: Bug #77701 [Opn->Ver]: \DateTime::createFromFormat does not set default parts
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219863@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77701&edit=1 ID: 77701 Updated by: requinix@php.net Reported by: zerkms at zerkms dot ru Summary: \DateTime::createFromFormat does not set default parts -Status: Open +Status: Verified Type: Bug Package: Date/time related Operating System: linux PHP Version: 7.3.2 Block user comment: N Private report: N New Comment: https://3v4l.org/ZpIWq Previous Comments: ------------------------------------------------------------------------ [2019-03-06 04:11:50] zerkms at zerkms dot ru Description: ------------ As documentation says (http://php.net/manual/en/datetime.createfromformat.php): If format does not contain the character ! then portions of the generated time which are not specified in format will be set to the current system time. While in php >= 7.3.0 it's not the case anymore. Date fractions are filled, but time are zeroed. ➜ docker run -v $(pwd):/app --rm php:7.2-cli php /app/dt.php int(1551845370) string(29) "2019-03-06T04:09:30.000+00:00" ➜ docker run -v $(pwd):/app --rm php:7.3-cli php /app/dt.php int(1551845374) string(29) "2019-03-06T00:00:00.000+00:00" Test script: --------------- <?php $now = \DateTime::createFromFormat('u', 0); var_dump(time(), $now->format(\DateTime::RFC3339_EXTENDED)); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77701&edit=1

« previous php.bugs (#219863) next »