2

I use unix time extensively throughout my scripts and usually I set my time zone as follows:

date_default_timezone_set('Europe/London');

This had been working fine until the clocks went back last weekend by an hour and I suspected this is related to the fact that in the US the clocks have not yet gone back and will not do until this coming weekend.

I can fix the issue by setting the time zone to UTC, but why is the Europe/London setting not working correctly. My server is based in the UK as far as I know.

Thanks,

Alan.

Alan A
  • 2,557
  • 6
  • 32
  • 54

1 Answers1

2

Europe/London isn't the same timezone as UTC. The UK observes daylight saving time, so during half the year, the timezone offset is UTC+1. Last weekend, daylight saving time has ended in Europe.

However, I suspect you're not using Unix time correctly. In PHP, time() always returns the current Unix timestamp regardless of time zone, if your clock is set correctly. If your timestamps have jumped by an hour, you're probably interpreting local time as UTC time.

As a side note, if you're specifying a time zone, you should always specify the timezone you're intending to use. If you want to use UTC, specify UTC. If you want to use the timezone that's being used in the UK, specify Europe/London. If for some reason the UK ever changes their time zone or DST rules, Europe/London will be updated with those changes.

Zr40
  • 1,910
  • 18
  • 20