PHP switch to BST (British Summer Time) timezone

Hi all,

Today I received an email with an issue in my code saying that the date time was 1 hour behind to the real time, why? easy, lots of countries, UK inclusive, adds an hour during summer time period for lots of reason I don’t want to describe here.

Is very useful get the proper date time 🙂

To get it, you should use a php native function to specify the timezone, and magically this method will take care about the summer time.

In the UK case you should use this line before your date time code.


date_default_timezone_set('Europe/London');

Try this code after this line:


$date = new \DateTime();

echo $date->format(\DateTime::ATOM);

Remove date_default_timezone_set line and run the code again, can you see the difference?

Hope this helps…