Edit report at http://bugs.php.net/bug.php?id=54597&edit=1
ID: 54597 Updated by: der...@php.net Reported by: kaldari at gmail dot com Summary: incorrect years for DateTime objects created with 4-digit years -Status: Open +Status: Assigned Type: Bug Package: Date/time related Operating System: MacOS X PHP Version: 5.3.6 -Assigned To: +Assigned To: derick Block user comment: N Private report: N 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 http://bugs.php.net/bug.php?id=54597&edit=1