|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74332 DateTime::createFromFormat(date) adds current time; but no microseconds
Submitted: 2017-03-29 12:38 UTC Modified: 2017-03-30 13:14 UTC
Avg. Score:3.5 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: sjon at hortensius dot net Assigned: derick (profile)
Status: Assigned Package: Date/time related
PHP Version: 7.1.3 OS:
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: sjon at hortensius dot net
New email:
PHP Version: OS:


 [2017-03-29 12:38 UTC] sjon at hortensius dot net
"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. "

Given that all datetime methods now include microseconds, DateTime::createFromFormat should do this as well

Test script:
var_dump(DateTime::createFromFormat('Y-m-d', '1980-01-01')->format('H:i:s.u'));

Expected result:
string(15) "14:35:58.283437"

Actual result:
string(15) "14:35:58.000000"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-30 13:14 UTC]
-Assigned To: +Assigned To: derick
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 25 22:03:37 2021 UTC