php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39928 Bogus timezone for dates before 1922
Submitted: 2006-12-22 00:47 UTC Modified: 2006-12-22 12:54 UTC
From: lafriks at hello dot lv Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.0 OS: Mandriva Linux 2007
Private report: No CVE-ID: None
 [2006-12-22 00:47 UTC] lafriks at hello dot lv
Description:
------------
When using new DateTime class it sets (or just formats) bogus timezone if year is before 1922. For year 1922 timezone is correct but for 1921 is showing wrong.

Reproduce code:
---------------
<?php
$a = new DateTime();
$a->setDate(1922, 1, 1);
$a->setTime(5, 3, 2);
echo $a->format(DateTime::W3C) . "\n";
$a->setDate(1921, 1, 1);
$a->setTime(5, 3, 2);
echo $a->format(DateTime::W3C) . "\n";
?>


Expected result:
----------------
1922-01-01T05:03:02+02:00
1921-01-01T05:03:02+02:00


Actual result:
--------------
1922-01-01T05:03:02+02:00
1921-01-01T05:03:02+01:39


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-22 08:44 UTC] derick@php.net
Which time zone setting are you using? See phpinfo() output for the value of the date.timezone setting.
 [2006-12-22 10:43 UTC] lafriks at hello dot lv
date
date/time support 	enabled
Timezone Database Version 	2006.14
Timezone Database 	internal
Default timezone 	Europe/Helsinki

Directive	Local Value	Master Value
date.default_latitude	31.7667	31.7667
date.default_longitude	35.2333	35.2333
date.sunrise_zenith	90.583333	90.583333
date.sunset_zenith	90.583333	90.583333
date.timezone	no value	no value
 [2006-12-22 11:02 UTC] lafriks at hello dot lv
When I changed in php.ini date.timezone to Europe/Riga what is what I should have. I get even stranger results:
<?php
$a = new DateTime();
for ($i = 2006; $i > 1900; $i--)
{
    $a->setDate($i, 1, 1);
    $a->setTime(5, 3, 2);
    echo $a->format(DateTime::W3C) . "<br />";
}
?>
Result:
2006-01-01T05:03:02+02:00
...
1990-01-01T05:03:02+02:00
1989-01-01T05:03:02+03:00
...
1945-01-01T05:03:02+03:00
1944-01-01T05:03:02+01:00
1943-01-01T05:03:02+01:00
1942-01-01T05:03:02+02:00
1941-01-01T05:03:02+03:00
1940-01-01T05:03:02+02:00
...
1927-01-01T05:03:02+02:00
1926-01-01T05:03:02+01:36
...
1901-01-01T05:03:02+01:36
PHP info:
date
date/time support 	enabled
Timezone Database Version 	2006.14
Timezone Database 	internal
Default timezone 	Europe/Riga

Directive	Local Value	Master Value
date.default_latitude	31.7667	31.7667
date.default_longitude	35.2333	35.2333
date.sunrise_zenith	90.583333	90.583333
date.sunset_zenith	90.583333	90.583333
date.timezone	Europe/Riga	Europe/Riga
 [2006-12-22 12:31 UTC] derick@php.net
How strange it might be, it is correct as the following entry in the time zone database illustrates:
# Zone  NAME            GMTOFF  RULES   FORMAT  [UNTIL]
Zone    Europe/Riga     1:36:24 -       LMT     1880
                        1:36:24 -       RMT     1918 Apr 15 2:00 #Riga Mean Time
                        1:36:24 1:00    LST     1918 Sep 16 3:00 #Latvian Summer
                        1:36:24 -       RMT     1919 Apr  1 2:00
                        1:36:24 1:00    LST     1919 May 22 3:00
                        1:36:24 -       RMT     1926 May 11
                        2:00    -       EET     1940 Aug  5

 [2006-12-22 12:54 UTC] lafriks at hello dot lv
ok, thanks did not know that, sorry for bogus bug report
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 12:01:29 2024 UTC