|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-03-09 15:23 UTC] nd dot wortel at gmail dot com
Description: ------------ A DateTime (or DateTimeImmutable) object can not be created with date '2369-12-31', '2769-12-31', '3169-12-31', etc. Instead, a DateTime object with date '2370-01-00' (or '2770-01-00', '3170-01-00', etc.) is created. This happens every 400 years on December 31st. Years in the past are not affected: '1969-12-31' and '1569-12-31' work just fine. Therefore, this has probably something to do with the Unix time system. Note: my PHP version is actually PHP 5.5.9-1ubuntu4.6. This bug is probably also causing the behavior described here: https://bugs.php.net/bug.php?id=67993 Test script: --------------- <?php $dateTime = new DateTime('2369-12-31'); // or 2769, 3169, etc. var_dump($dateTime); Expected result: ---------------- object(DateTime)[1] public 'date' => string '2369-12-31 00:00:00' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'Europe/Amsterdam' (length=16) Actual result: -------------- object(DateTime)[1] public 'date' => string '2370-01-00 00:00:00' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'Europe/Amsterdam' (length=16) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
This also appears to be demonstrating the same or similiar problem <?php $test = date_create("-1000-12-27"); echo date_format($test, 'Y-m-d H:i:s').PHP_EOL; date_modify($test, '+1 day'); echo date_format($test, 'Y-m-d H:i:s').PHP_EOL.PHP_EOL; $test = date_create("-2000-12-27"); echo date_format($test, 'Y-m-d H:i:s').PHP_EOL; date_modify($test, '+1 day'); echo date_format($test, 'Y-m-d H:i:s').PHP_EOL.PHP_EOL; $test = date_create("-3000-12-27"); echo date_format($test, 'Y-m-d H:i:s').PHP_EOL; date_modify($test, '+1 day'); echo date_format($test, 'Y-m-d H:i:s').PHP_EOL.PHP_EOL; RESULTS: -1000-12-28 00:00:00 -1000-12-30 00:00:00 -2000-12-27 00:00:00 -2000-12-28 00:00:00 -3000-12-28 00:00:00 -3000-12-30 00:00:00