UK Time

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

Related guides