colorful old fashioned clock in city

Get correct UK time in PHP on Windows (including daylight savings time)

When running on Windows, PHP’s timezones don’t always play nicely with the Windows implementation of daylight savings time (DST). The code below is an easy workaround to this; simple use date("I") to work out if it is summer or not and combine this with date() and strtotime() to get the spot-on time including your GMT offset.

For the UK the DST offset is 1 hour, so the following works perfectly:

date('Y-m-d H:i:s',strtotime('-' . date("I") . 'hours'))

Leave a Reply