Handling UK Time in Code: JavaScript, Python and Excel
Software gets UK time wrong when it treats the UK as a fixed offset. Using the Europe/London time zone makes the clock change automatic.
JavaScript
Use the built-in Intl.DateTimeFormat with the timeZone option set to 'Europe/London' to display UK time, for example new Intl.DateTimeFormat('en-GB', { timeZone: 'Europe/London', dateStyle: 'full', timeStyle: 'long' }). The browser applies GMT or BST for you.
Store timestamps as UTC milliseconds or ISO strings ending in Z, and convert for display only. Avoid adding 3,600,000 milliseconds by hand to move between GMT and BST.
Python
From Python 3.9 the standard library has zoneinfo. Use datetime.now(ZoneInfo('Europe/London')) for the current UK time, and astimezone(ZoneInfo('Europe/London')) to convert a UTC value. Keep timezone-aware datetimes throughout, not naive ones.
Excel and spreadsheets
Excel has no built-in time zone support. Store times in UTC, then add one hour in summer with a formula that checks whether the date falls between the last Sunday of March and the last Sunday of October. Google Sheets can use the NOW function with the spreadsheet time zone set to London in File, Settings.
For scheduled jobs, run in UTC where you can. A job set for 01:30 UK time runs twice in October and not at all in March.
Frequently asked questions
What is the correct time zone name for the UK?
Europe/London. It covers England, Scotland, Wales and Northern Ireland, and applies GMT and BST automatically.
Clock change guides
- What Is Daylight Saving Time (DST)? A Plain-English GuideWhat daylight saving time is, how it works in the UK, Europe and the US, why it exists, its history, who uses it and the argument over scrapping it.
- Why Do the Clocks Go Back in October? The Real ReasonThe clocks go back in autumn to return the UK to GMT, so winter mornings are lighter. The history, the rule, what time it happens and what changes for you.
- When Do the Clocks Go Forward Again After Going Back?When the UK clocks go forward again after the autumn change, how long the UK stays on GMT, when evenings get lighter and how to remember to reset your clocks.