Doc #77701 [Ver->Csd]: \DateTime::createFromFormat does not set default parts
| From: | git@php.net | Date: | Thu, 02 Jun 2022 15:52:00 +0000 |
| Subject: | Doc #77701 [Ver->Csd]: \DateTime::createFromFormat does not set default parts | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-19454@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: git@php.net
Reported by: zerkms at zerkms dot ru
Summary: \DateTime::createFromFormat does not set default
parts
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: Date/time related
Operating System: linux
PHP Version: 7.3.2
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of derickr
Revision: https://github.com/php/doc-en/commit/e5373bc7610639edca743a5d190e78e6cf41b42f
Log: Fixed bug #77701: DateTime::createFromFormat does not set default parts
Previous Comments:
------------------------------------------------------------------------
[2022-05-20 14:52:55] derick@php.net
I am marking this as Documentation Problems, as this behaviour is now long standing, and not only
applicable for the 'u' character. The same behaviour occurs for other time related
characters too.
We can break this behaviour again, but I am not really willing to do so.
------------------------------------------------------------------------
[2019-03-06 04:23:34] requinix@php.net
https://3v4l.org/ZpIWq
------------------------------------------------------------------------
[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