php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44264 On some dates timezone goes wrong
Submitted: 2008-02-27 13:42 UTC Modified: 2008-03-03 22:23 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kungla at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.5 OS: Win XP SP2 AND OSX Leopard
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kungla at gmail dot com
New email:
PHP Version: OS:

 

 [2008-02-27 13:42 UTC] kungla at gmail dot com
Description:
------------
On some dates timezone goes wrong. Big problem for me - can't go on whith my work!!!

Reproduce code:
---------------
$date1 = new Date('02.01.1980', new DateTimeZone('Europe/Tallinn'));
$date2 = new Date('02.01.1990', new DateTimeZone('Europe/Tallinn'));
echo $date1->format('c'). ' ' . $date2->format('c');

Expected result:
----------------
1980-01-02T00:00:00+02:00 1990-01-02T00:00:00+02:00

Actual result:
--------------
1980-01-02T00:00:00+03:00 1990-01-02T00:00:00+02:00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-27 13:46 UTC] kungla at gmail dot com
Sorry class is DateTime not Time. Same issue with date('c', giventime)
 [2008-02-27 13:56 UTC] derick@php.net
The returned data is perfectly correct. From 1944 until 1981 Tallinn used Moscow time with Daylight Savings Time.

Europe/Tallinn  Thu Sep 21 22:00:00 1944 UTC = Fri Sep 22 01:00:00 1944 MSK isdst=0 gmtoff=10800
Europe/Tallinn  Tue Mar 31 20:59:59 1981 UTC = Tue Mar 31 23:59:59 1981 MSK isdst=0 gmtoff=10800

From 1981 to 1989 moscow timw with DST:

Europe/Tallinn  Tue Mar 31 20:59:59 1981 UTC = Tue Mar 31 23:59:59 1981 MSK isdst=0 gmtoff=10800
Europe/Tallinn  Tue Mar 31 21:00:00 1981 UTC = Wed Apr  1 01:00:00 1981 MSD isdst=1 gmtoff=14400
Europe/Tallinn  Wed Sep 30 19:59:59 1981 UTC = Wed Sep 30 23:59:59 1981 MSD isdst=1 gmtoff=14400
Europe/Tallinn  Wed Sep 30 20:00:00 1981 UTC = Wed Sep 30 23:00:00 1981 MSK isdst=0 gmtoff=10800
...
...
Europe/Tallinn  Sat Sep 24 23:00:00 1988 UTC = Sun Sep 25 02:00:00 1988 MSK isdst=0 gmtoff=10800
Europe/Tallinn  Sat Mar 25 22:59:59 1989 UTC = Sun Mar 26 01:59:59 1989 MSK isdst=0 gmtoff=10800

From 1989 until now, Estonia switched to the non-russian zone with DST:
Europe/Tallinn  Sat Mar 25 23:00:00 1989 UTC = Sun Mar 26 02:00:00 1989 EEST isdst=1 gmtoff=10800
Europe/Tallinn  Sat Sep 23 23:59:59 1989 UTC = Sun Sep 24 02:59:59 1989 EEST isdst=1 gmtoff=10800
Europe/Tallinn  Sun Sep 24 00:00:00 1989 UTC = Sun Sep 24 02:00:00 1989 EET isdst=0 gmtoff=7200
Europe/Tallinn  Sat Mar 24 23:59:59 1990 UTC = Sun Mar 25 01:59:59 1990 EET isdst=0 gmtoff=7200
Europe/Tallinn  Sun Mar 25 00:00:00 1990 UTC = Sun Mar 25 03:00:00 1990 EEST isdst=1 gmtoff=10800
...
...
Europe/Tallinn  Sun Mar 30 00:59:59 2008 UTC = Sun Mar 30 02:59:59 2008 EET isdst=0 gmtoff=7200
Europe/Tallinn  Sun Mar 30 01:00:00 2008 UTC = Sun Mar 30 04:00:00 2008 EEST isdst=1 gmtoff=10800
Europe/Tallinn  Sun Oct 26 00:59:59 2008 UTC = Sun Oct 26 03:59:59 2008 EEST isdst=1 gmtoff=10800
Europe/Tallinn  Sun Oct 26 01:00:00 2008 UTC = Sun Oct 26 03:00:00 2008 EET isdst=0 gmtoff=7200

If you are 100% sure that this data is incorrect, and you can back that up with proof, let me know.
 [2008-02-27 21:34 UTC] kungla at gmail dot com
No I tested this on OSX leopard - same issue. I did some more examples.

Reproduce code:
---------------
<?php
date_default_timezone_set('Europe/Tallinn'); 
$date1 = new DateTime('02.01.1980', new DateTimeZone('Europe/Tallinn'));
$date2 = new DateTime('02.01.1990', new DateTimeZone('Europe/Tallinn'));

echo 'Date1<br/>';
echo $date1->format('c'). ' ' . $date1->getTimezone()->getName();
echo '<br/><br/>';
echo 'Date2<br/>';
echo $date2->format('c'). ' ' . $date2->getTimezone()->getName();
echo '<br/><br/>';
echo "date('c', strtotime('02.01.1980'))<br/>";
echo date('c', strtotime('02.01.1980'));
echo '<br/><br/>';

$date3 = new DateTime('-38 years', new DateTimeZone('Europe/Tallinn'));
echo 'Date3<br/>';
echo $date3->format('c'). ' ' . $date3->getTimezone()->getName();


echo '<br/><br/>';
date_default_timezone_set('GMT');
echo "date('c', strtotime('02.01.1980')) with date_default_timezone_set('GMT') and working<br/>";
echo date('c', strtotime('02.01.1980')); 
?>

Expected result:
----------------
Date1
1980-01-02T00:00:00+02:00 Europe/Tallinn

Date2
1990-01-02T00:00:00+02:00 Europe/Tallinn

date('c', strtotime('02.01.1980'))
1980-01-02T00:00:00+02:00

Date3
1970-02-27T23:28:00+02:00 Europe/Tallinn

date('c', strtotime('02.01.1980')) with date_default_timezone_set('GMT') and working
1980-01-02T00:00:00+00:00

Actual result:
--------------
Date1
1980-01-02T00:00:00+03:00 Europe/Tallinn

Date2
1990-01-02T00:00:00+02:00 Europe/Tallinn

date('c', strtotime('02.01.1980'))
1980-01-02T00:00:00+03:00

Date3
1970-02-27T23:28:00+03:00 Europe/Tallinn

date('c', strtotime('02.01.1980')) with date_default_timezone_set('GMT') and working
1980-01-02T00:00:00+00:00
 [2008-03-03 22:23 UTC] kungla at gmail dot com
I found an workaround (I am creating dates from ISO_8601 ), but bug is still there!!! I see that tatus is still Bogus?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 04 18:00:01 2025 UTC