Bug #54597 [NEW]: incorrect years for DateTime objects created with 4-digit years
| From: | kaldari at gmail dot com | Date: | Sun, 24 Apr 2011 04:50:14 +0000 |
| Subject: | Bug #54597 [NEW]: incorrect years for DateTime objects created with 4-digit years | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-160347@lists.php.net to get a copy of this message | ||
From:
Operating system: MacOS X
PHP version: 5.3.6
Package: Date/time related
Bug Type: Bug
Bug description:incorrect years for DateTime objects created with 4-digit years
Description:
------------
---
From manual page: http://www.php.net/datetime.construct
---
I'm actually using PHP 5.3.2. Apologies for not testing against 5.3.6.
DateTime objects created with any of the following strings result in
incorrect years:
'January 0099' -> 1999
'January 1, 0099' -> 1999
'0099-01' -> 1999
However, all of the following work correctly:
'0099' -> 0099
'0099-01-01' -> 0099
'01-01-0099' -> 0099
I imagine this is due to DateTime parsing 0099 into 99 in the bad examples
(and thus triggering the 1900 addition). This bug currently blocks the
following MediaWiki bug:
https://bugzilla.wikimedia.org/show_bug.cgi?id=28655
Test script:
---------------
$tz = new DateTimeZone("Europe/Amsterdam");
$dateObject = new DateTime( 'January 0099', $tz );
echo $dateObject->format( 'Y' );
$dateObject = new DateTime( 'January 1, 0099', $tz );
echo $dateObject->format( 'Y' );
$dateObject = new DateTime( '0099-01', $tz );
echo $dateObject->format( 'Y' );
Expected result:
----------------
0099
0099
0099
Actual result:
--------------
1999
1999
1999
--
Edit bug report at http://bugs.php.net/bug.php?id=54597&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54597&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54597&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54597&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54597&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54597&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54597&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54597&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54597&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54597&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54597&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54597&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54597&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54597&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54597&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54597&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54597&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54597&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54597&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54597&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54597&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54597&r=mysqlcfg