Bug #81562 [NEW]: DateTime returns incorrect time on a very specific date (1895-01-01)

From: Date: Thu, 28 Oct 2021 18:32:33 +0000
Subject: Bug #81562 [NEW]: DateTime returns incorrect time on a very specific date (1895-01-01)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237422@lists.php.net to get a copy of this message
From: abrlam at yahoo dot com Operating system: Ubuntu 18.04.4 LTS PHP version: Irrelevant Package: Date/time related Bug Type: Bug Bug description:DateTime returns incorrect time on a very specific date (1895-01-01) Description: ------------ When time zone is set as America/Toronto, DateTime returns incorrect time on a very specific date (1895-01-01). This happens in PHP version 7.4.20 and possibly in earlier versions (>=7.3.5). Test script: --------------- //fails in 1895-01-01 for($i = 1890; $i <= 1910 ; $i++) { $date = new DateTime( $i. '-01-01', new DateTimeZone('America/Toronto')); echo $date->format('Y-m-d H:i:s') . "<br />"; } Expected result: ---------------- For 1895-01-01, it should be 1895-01-01 00:00:00 instead of 1895-01-01 00:17:32. Actual result: -------------- 1890-01-01 00:00:00 1891-01-01 00:00:00 1892-01-01 00:00:00 1893-01-01 00:00:00 1894-01-01 00:00:00 1895-01-01 00:17:32 <========== Expected value: 1895-01-01 00:00:00 1896-01-01 00:00:00 1897-01-01 00:00:00 1898-01-01 00:00:00 1899-01-01 00:00:00 1900-01-01 00:00:00 1901-01-01 00:00:00 1902-01-01 00:00:00 1903-01-01 00:00:00 1904-01-01 00:00:00 1905-01-01 00:00:00 1906-01-01 00:00:00 1907-01-01 00:00:00 1908-01-01 00:00:00 1909-01-01 00:00:00 1910-01-01 00:00:00 -- Edit bug report at https://bugs.php.net/bug.php?id=81562&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81562&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81562&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81562&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81562&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81562&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81562&r=support Expected behavior: https://bugs.php.net/fix.php?id=81562&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81562&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81562&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81562&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81562&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81562&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81562&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81562&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81562&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81562&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81562&r=mysqlcfg

« previous php.bugs (#237422) next »