|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80057 DateTimeImmutable::createFromFormat() does not populate time
Submitted: 2020-09-04 10:16 UTC Modified: -
From: bc at benjamin-cremer dot de Assigned:
Status: Closed Package: Date/time related
PHP Version: 8.0.0beta3 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: bc at benjamin-cremer dot de
New email:
PHP Version: OS:


 [2020-09-04 10:16 UTC] bc at benjamin-cremer dot de
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) {
  string(26) "2020-09-04 10:28:48.000000"
  string(16) "Europe/Amsterdam"

Output from 8.0.0beta3:
object(DateTimeImmutable)#1 (3) {
  string(26) "2020-09-04 00:00:00.000000"
  string(16) "Europe/Amsterdam"

Test script:

var_dump(DateTimeImmutable::createFromFormat('Y-m-d', '2020-09-04')->format('His') > 0);

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-04 14:55 UTC]
Automatic comment on behalf of
Log: Fixed bug #80057 (DateTimeImmutable::createFromFormat() does not populate time)
 [2020-09-04 14:55 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 02:01:30 2024 UTC