php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77701 \DateTime::createFromFormat does not set default parts
Submitted: 2019-03-06 04:11 UTC Modified: 2019-03-06 04:23 UTC
From: zerkms at zerkms dot ru Assigned:
Status: Verified Package: Date/time related
PHP Version: 7.3.2 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-03-06 04:11 UTC] 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));


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-06 04:23 UTC] requinix@php.net
-Status: Open +Status: Verified
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 00:01:25 2019 UTC