|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45483 Add an era designater to DateTime methods when formatting or parsing dates
Submitted: 2008-07-11 10:18 UTC Modified: 2017-10-24 07:52 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: tj at systisoft dot com Assigned:
Status: Open Package: Date/time related
PHP Version: 5.3CVS-2008-07-11 (CVS) OS: All
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-11 10:18 UTC] tj at systisoft dot com
It is currently not possible to specify an era designator in a format when parsing or formatting dates with DateTime::createFromFormat or DateTime::format.

An era designater would be BC or AD as in 1/1/0200 BC or 1/1/2004 AD.

I don't know which format char would be good since 'G' which is used in some other format patterns as era designator seems to be already taken.

Reproduce code:

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-15 11:47 UTC] tj at systisoft dot com
There should also be a possibility to format a year without the sign, because if you format with 'Y' you will get something like:

-2000 BC

This can either be done by an new format char for unsigned year or that the 'Y' format is omitting the sign when a format char for the era designator is present.
 [2008-07-17 08:50 UTC] tj at systisoft dot com
On further thinking there should be a new format char for BC dates because Y formats the date with year 0 which is conforming with ISO8601.

But years in the proleptic Gregorian calendar do not have a year 0. The year 0 in ISO8601 is 1 BC in the proleptic Gregorian calendar.
 [2010-12-20 14:25 UTC]
-Package: Feature/Change Request +Package: Date/time related
 [2017-10-24 07:52 UTC]
-Status: Assigned +Status: Open -Assigned To: derick +Assigned To:
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jul 27 00:01:25 2021 UTC