#41844 [NEW]: Format returns incorrect number of digits for negative years -0001 to -0999
From: mattsch at gmail dot com
Operating system: Gentoo Linux 2007.0
PHP version: 5.2.3
PHP Bug Type: Date/time related
Bug description: Format returns incorrect number of digits for negative years -0001 to -0999
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 bug report at http://bugs.php.net/?id=41844&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41844&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41844&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41844&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41844&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41844&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41844&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41844&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41844&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41844&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41844&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41844&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41844&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41844&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41844&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41844&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41844&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41844&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41844&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41844&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41844&r=mysqlcfg
Thread (4 messages)
- mattsch at gmail dot com