Bug #54597 [Asn->Csd]: incorrect years for DateTime objects created with 4-digit years
| From: | derick@php.net | Date: | Fri, 25 Nov 2011 15:51:35 +0000 |
| Subject: | Bug #54597 [Asn->Csd]: incorrect years for DateTime objects created with 4-digit years | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165501@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54597&edit=1
ID: 54597
Updated by: derick@php.net
Reported by: kaldari at gmail dot com
Summary: incorrect years for DateTime objects created with
4-digit years
-Status: Assigned
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: MacOS X
PHP Version: 5.3.6
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2011-04-24 06:50:14] kaldari at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=54597&edit=1