|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45509 create_date_from_format() cannot parse negative (BC) dates
Submitted: 2008-07-14 13:29 UTC Modified: 2015-08-28 01:11 UTC
Avg. Score:4.1 ± 0.8
Reproduced:3 of 4 (75.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: tj at systisoft dot com Assigned: derick (profile)
Status: Assigned Package: Date/time related
PHP Version: 5.3CVS-2008-11-11 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: tj at systisoft dot com
New email:
PHP Version: OS:


 [2008-07-14 13:29 UTC] tj at systisoft dot com
While the constructor of DateTime can handle negaive dates (BC dates), create_date_from_format cannot.

Reproduce code:
$d = new DateTime("-4000-01-31"); echo $d->format("Y-m-d"), PHP_EOL;
$d = date_create_from_format("Y-m-d", "4000-01-31"); echo $d->format("Y-m-d"), PHP_EOL;
$d = date_create_from_format("Y-m-d", "-4000-01-31"); echo $d->format("Y-m-d"), PHP_EOL;

Expected result:

Actual result:
PHP Fatal error:  Call to a member function format() on a non-object in Command line code on line 3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-28 01:11 UTC]
-Type: Bug +Type: Feature/Change Request
 [2015-08-28 01:11 UTC]
Well, the "Y" format specifier expects a four-digit year – so
actually this is not a bug. I'm changing to feature request.
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC