[php-src] Issue #14142: DateTime with Timezone have different timestamps for End of Year. Only on certain years and time zones

From: Date: Sun, 05 May 2024 18:51:55 +0000
Subject: [php-src] Issue #14142: DateTime with Timezone have different timestamps for End of Year. Only on certain years and time zones
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246860@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/14142 Author: steinger ### Description When creating a calendar, I noticed that certain years with the end year date and time zone the output was shifted into the new year. I tested this output for some time zones from 1900 to 3000. It was interesting that this only happened at certain years. During my investigations, I discovered this with different operating systems as well as different PHP versions. ```php <?php $dt = new DateTime("1923-12-31 23:59:59", new DateTimeZone("Asia/Jakarta")) var_dump($dt); ``` Resulted in this output: ``` object(DateTime)#1 (3) { ["date"]=> string(26) "1924-01-01 00:12:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Asia/Jakarta" } ``` But I expected this output instead: ``` object(DateTime)#1 (3) { ["date"]=> string(26) "1923-12-31 23:59:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Asia/Jakarta" } ``` _All other years are correct for this time zone, only 1923 has a different output._ **I also found this phenomenon with the following settings.** new DateTime("1900-12-31 23:59:59", new DateTimeZone("Europe/Madrid")); -> Output: 1901-01-01 00:14:43 new DateTime("1911-12-31 23:59:59", new DateTimeZone("Europe/Lisbon")); -> Output: 1912-01-01 00:36:44 new DateTime("1981-12-31 23:59:59", new DateTimeZone("Asia/Kuala_Lumpur")); -> Output: 1982-01-01 00:29:59 new DateTime("1981-12-31 23:59:59", new DateTimeZone("Asia/Singapore")); -> Output: 1982-01-01 00:29:59 **The same effect at the end of the month, here are a few examples** new DateTime("1916-04-30 23:59:59", new DateTimeZone("Europe/Berlin")); -> Output: 1916-05-01 00:59:59 new DateTime("1916-04-30 23:59:59", new DateTimeZone("Europe/Vienna")); -> Output: 1916-05-01 00:59:59 new DateTime("1916-04-30 23:59:59", new DateTimeZone("Europe/Warsaw")); -> Output: 1916-05-01 00:59:59 new DateTime("1916-04-30 23:59:59", new DateTimeZone("Europe/Budapest")); -> Output: 1916-05-01 00:59:59 new DateTime("1916-04-30 23:59:59", new DateTimeZone("Europe/Prague")); -> Output: 1916-05-01 00:59:59 new DateTime("1916-04-30 23:59:59", new DateTimeZone("Europe/Bratislava")); -> Output: 1916-05-01 00:59:59 new DateTime("1979-03-31 23:59:59", new DateTimeZone("Europe/Sofia")); -> Output: 1979-04-01 00:59:59 new DateTime("1919-05-31 23:59:59", new DateTimeZone("Europe/Moscow")); -> Output: 1919-06-01 00:59:59 ### PHP Version PHP 8.3.6 ### Operating System Ubuntu 22.04

« previous php.bugs (#246860) next »