Bug #81562 [Com]: DateTime returns incorrect time on a very specific date (1895-01-01)
| From: | sschueller at techdroid dot com | Date: | Mon, 14 Mar 2022 15:44:00 +0000 |
| Subject: | Bug #81562 [Com]: DateTime returns incorrect time on a very specific date (1895-01-01) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-240339@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81562&edit=1
ID: 81562
Comment by: sschueller at techdroid dot com
Reported by: abrlam at yahoo dot com
Summary: DateTime returns incorrect time on a very specific
date (1895-01-01)
Status: Verified
Type: Bug
Package: Date/time related
Operating System: Ubuntu 18.04.4 LTS
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Please ignore my previous comment. The timezone output seems correct for this region regarding
historical events.
Previous Comments:
------------------------------------------------------------------------
[2022-03-14 14:42:41] sschueller at techdroid dot com
<?php
for ($i = 0000; $i <= 2025; $i++) {
$tz1 = new DateTime($i.'-01-01 00:00:00', new
\DateTimeZone('Europe/Zurich'));
echo $tz1->format('c') . "\n";
}
Timezone is wrong between 0000-1895,
....
1782-01-01T00:00:00+00:34
1783-01-01T00:00:00+00:34
1784-01-01T00:00:00+00:34
1785-01-01T00:00:00+00:34
1786-01-01T00:00:00+00:34
1787-01-01T00:00:00+00:34
1788-01-01T00:00:00+00:34
....
1889-01-01T00:00:00+00:29
1890-01-01T00:00:00+00:29
1891-01-01T00:00:00+00:29
1892-01-01T00:00:00+00:29
1893-01-01T00:00:00+00:29
1894-01-01T00:00:00+00:29
1895-01-01T00:00:00+01:00
1896-01-01T00:00:00+01:00
....
Using 'CET' instead works for all years starting from 0000. I can firm this issues in 7.4
and 8.1.
------------------------------------------------------------------------
[2021-11-12 15:46:13] antonino dot spampinato86 at gmail dot com
Related To: Bug #81565
------------------------------------------------------------------------
[2021-10-29 11:29:08] cmb@php.net
Confirmed: <https://3v4l.org/NLAnOY>.
This is apparently caused by the uncommon timezone transition on
that particular date[1], where the minutes and seconds are not
properly handled.
[1] <https://3v4l.org/VEUib>
------------------------------------------------------------------------
[2021-10-28 18:32:33] abrlam at yahoo dot com
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 this bug report at https://bugs.php.net/bug.php?id=81562&edit=1