|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 18:00:01 2025 UTC |
Sorry class is DateTime not Time. Same issue with date('c', giventime)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