From:             mattsch at gmail dot com
Operating system: Gentoo Linux 2007.0
PHP version:      5.2.4RC2
PHP Bug Type:     Date/time related
Bug description:  Unable to create dates with years <= -10000 and >= 10000

Description:
------------
I am unable to create dates with years <= -10000 and >= 10000.  ISO
8601:2004E allows for this under Expanded representations:

http://isotc.iso.org/livelink/livelink/4021199/ISO_8601_2004_E.zip?func=doc.Fetch&nodeid=4021199

ISO 8601:2004(E)
14 © ISO 2004 – All rights reserved
4.1.2.4 Expanded representations
If, by agreement, expanded representations are used, the formats shall be
as specified below. The
interchange parties shall agree the additional number of digits in the
time element year. In the examples below
it has been agreed to expand the time element year with two digits.
a) A specific day
Basic format: ±YYYYYMMDD Example: +0019850412
Extended format: ±YYYYY-MM-DD Example: +001985-04-12
b) A specific month
Basic format: ±YYYYY-MM Example: +001985-04
Extended format: not applicable
c) A specific year
Basic format: ±YYYYY Example: +001985
Extended format: not applicable
d) A specific century
Basic format: ±YYY Example: +0019
Extended format: not applicable

Reproduce code:
---------------
Negative year:

<?php
$date = new DateTime('-10000-01-01 00:00:00');
echo $date->format('Y-m-d H:i:s');
?>

Positive year:

<?php
$date = new DateTime('10000-01-01 00:00:00');
echo $date->format('Y-m-d H:i:s');
?>

Expected result:
----------------
Negative year outputs:

-10000-01-01 00:00:00

Positive year outputs:

10000-01-01 00:00:00

Actual result:
--------------
Negative year outputs:

2000-01-01 00:00:00

Positive year outputs:

Fatal error: Uncaught exception 'Exception' with message
'DateTime::__construct(): Failed to parse time string (10000-01-01
00:00:00) at position 12 (0): Double time specification' in /test.php:5
Stack trace:
#0 /test.php(5): DateTime->__construct('10000-01-01 00:...')
#1 {main}
  thrown in /test.php on line 5

-- 
Edit bug report at http://bugs.php.net/?id=42351&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42351&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42351&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42351&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42351&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42351&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42351&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42351&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42351&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42351&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42351&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42351&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42351&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42351&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42351&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42351&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42351&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42351&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42351&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42351&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42351&r=mysqlcfg

Reply via email to