ID: 41844 User updated by: mattsch at gmail dot com Reported By: mattsch at gmail dot com Status: Open Bug Type: Date/time related Operating System: Gentoo Linux 2007.0 PHP Version: 5.2.3 New Comment:
I didn't mean to link the colon: http://en.wikipedia.org/wiki/Year_zero Previous Comments: ------------------------------------------------------------------------ [2007-06-28 17:30:18] mattsch at gmail dot com Description: ------------ Format returns incorrect number of digits for negative years -0001 to -0999. See ISO 8601:2004 and http://en.wikipedia.org/wiki/Year_zero: The "basic" format for year 0 is the four-digit form 0000, which equals the historical year 1 BC. Several "expanded" formats are possible: -0000 and +0000, as well as five- and six-digit versions. Earlier years are also negative four-, five- or six-digit years, which have an absolute value one less than the equivalent BC year, hence -0001 = 2 BC. Reproduce code: --------------- <? $date = new DateTime('2007-06-28'); $date->modify('-3006 years'); echo $date->format(DATE_ISO8601); ?> Outputs: -999-06-17T00:00:00-0600 Expected: -0999-06-17T00:00:00-0600 <? $date = new DateTime('2007-06-28'); $date->modify('-2008 years'); echo $date->format(DATE_ISO8601); ?> Outputs: -001-06-17T00:00:00-0600 Expected: -0001-06-17T00:00:00-0600 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41844&edit=1