5

Learning dates and they're giving me hard time right now.

$london = new DateTime();
$london->setTimestamp(0);
$london->setTimeZone(new DateTimeZone('Europe/London'));

echo $london ->format('d-m-Y H-i-s');

result:

01-01-1970 01-00-00

Shouldn't be London in UTC +0:00 therefore midnight? For example, New York returns 19:00 of the previous date which is correctly UTC -5:00. Moscow returns 01-01-1970 03-00-00 which is again incorrect (UTC +3:00 as opposed to UTC +4:00)

When not using ->setTimestamp, the London current time renders correctly, though.

Livecode: http://sandbox.onlinephpfunctions.com/

Also, my local timezone is Europe/Prague (UTC +1:00). Tested with date_default_timezone_set('Europe/London') as well.

I presume there's some error in my logic?

dwelle
  • 6,894
  • 2
  • 46
  • 70

1 Answers1

12

This is because apparently, Great Britain was on British Summer Time on January 1, 1970, one hour ahead of UTC (emphasis mine):

An inquiry during the winter of 1959–60, in which 180 national organisations were consulted, revealed a slight preference for a change to all-year GMT+1, but the length of summer time was extended as a trial rather than the domestic use of Greenwich Mean Time abolished.[6] A further inquiry during 1966–67 led the government of Harold Wilson to introduce the British Standard Time experiment, with Britain remaining on GMT+1 throughout the year. This took place between 27 October 1968 and 31 October 1971, when there was a reversion to the previous arrangement.

timeanddate.com's Time Zone Converter is a great tool for finding out stuff like this.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • @hohner lol! Thinking about it, though, I wouldn't be surprised if this had a duplicate somewhere.... – Pekka Feb 16 '13 at 14:06
  • Wow, I've never known. Makes me wanna dust of my nonexistent pile of history books. I guess Russia did something similar? – dwelle Feb 16 '13 at 14:13
  • 2
    @DavidL: MSK (Moscow standard time) was UTC+3 until 2011 (and UTC+4 summer time (MSD)). Now MSK is UTC+4 all year round. – jfs Feb 16 '13 at 14:22