StopwatchHQ

Timezone-Safe Countdowns: Building Timers That Survive DST

I computed the same countdown across eight daylight-saving changes in four zones for 2027. Every one of them comes out an hour wrong if you build it out of calendar fields. Here are the numbers, the rule that fixes it, and how to test your own code before next March.

Somebody in London sets a countdown at 22:00 on Saturday 27 March 2027, for 09:00 the next morning. Eleven hours, by the calendar. The clocks go forward at 01:00 UTC, so those eleven hours contain only ten, and the timer fires an hour early. Reverse it in October and it fires an hour late.

I've fixed this in systems where being an hour out meant a batch job missing its window, so I ran it properly for 2027 rather than repeating what the blog posts say. Eight transitions, four zones, one countdown each.

Two different things get called "the time"

You have a label, which is what a clock on a wall shows, and you have an instant, which is a point on one continuous line. Countdowns need the instant. Calendar arithmetic gives you the label, and then quietly assumes every day is 24 hours long.

That assumption is true most of the year, which is why the bug survives testing. It's wrong on the two days a year when a local day has 23 hours or 25.

What the measurement shows

One countdown per transition, from 22:00 local on the evening before to 09:00 local the following morning. Both ends are unambiguous local times in every zone I tested, so nothing here depends on how a library resolves a repeated or missing hour. Naive arithmetic gives 660 minutes every time, because it subtracts calendar fields and assumes 11 hours is 11 hours.

ZoneChange (UTC)DirectionNaiveRealError
Europe/London2027-03-28 01:00forward660 min600 min-60
Europe/London2027-10-31 01:00back660 min720 min+60
Europe/Zagreb2027-03-28 01:00forward660 min600 min-60
Europe/Zagreb2027-10-31 01:00back660 min720 min+60
America/New_York2027-03-14 07:00forward660 min600 min-60
America/New_York2027-11-07 06:00back660 min720 min+60
Australia/Sydney2027-04-03 16:00back660 min720 min+60
Australia/Sydney2027-10-02 16:00forward660 min600 min-60

Two things worth knowing about the dates. The EU and UK change at the same instant, 01:00 UTC, which is why London and Zagreb are identical here even though their local clocks read differently. The United States and Canada change in March and early November. In Australia only some states observe daylight saving at all, and it runs the other way round: forward in October, back in April.

The part that catches people implementing it

Converting a wall time to an instant isn't a single answer on two mornings a year. In spring some local times don't exist. In autumn some happen twice. My first version of this harness returned 480 minutes for London in October and 540 for Zagreb on the same date; the difference wasn't the zones, it was that the conversion happened to land on a different one of the two possible 01:00s. If you write a converter without saying which you mean, you get a number that looks measured and isn't.

State the policy in the code and in the comment: for a repeated local time, take the earliest instant; for a missing one, take the first instant after the gap. That's what Temporal.ZonedDateTime calls disambiguation: "earlier" and "compatible", and it's what the harness behind the table does.

The rules I'd apply

Store an instant, not a label. The moment the user picks a target, convert it once with an explicit zone and keep the milliseconds. After that the calendar has nothing left to contribute.

Subtract instants, don't decrement a counter. Math.max(0, target - Date.now()) is the engine. It's right after a hidden tab, after the laptop sleeps, and after the tab is closed and reopened, because nothing is being accumulated.

Format with a zone, and only at the end. The remaining time is a duration and needs no zone. Anything that shows a clock reading gets Intl.DateTimeFormat with an explicit timeZone. Don't hand calendar fields to the Date constructor and hope.

Recurrences store a wall time and a zone name. "Every day at 07:00" isn't a countdown. Keep 07:00 plus Europe/London, and compute the next instant after each fire. Store a fixed UTC offset instead and it's wrong from the next transition onwards. Store nothing but an interval and it drifts the moment someone changes the rules, which governments do.

Being honest about Date.now() and performance.now()

Date.now() is the system clock. It survives sleep and hidden tabs, and it does not survive someone changing the clock or NTP stepping it: your countdown jumps with it. performance.now() is monotonic and immune to that, but it resets on reload, so it can't carry state across a closed tab.

For countdowns I use the wall clock, because a countdown to a real-world event is a claim about calendar time, and reloading must not reset it. For measuring elapsed time inside one session, the monotonic clock is the better instrument. Different jobs, different clocks, and it's worth not pretending one of them does both.

What this site does

I checked the engine rather than trusting my memory of it. The countdown keeps an end timestamp and recomputes Math.max(0, endAt - Date.now()) on every paint, and the stopwatch accumulates Date.now() deltas rather than counting ticks. The paint loop is requestAnimationFrame, and it's allowed to be late, because it isn't the clock. Close the tab during a countdown and reopen it later and the number is still right, since the deadline was stored and not the remaining time.

Testing your own before March

You don't have to wait for the transition. Node ships the full timezone database, and Intl takes an explicit zone, so you can compute any date you like on any machine. Resolve 00:00 on 28 March 2027 and 00:00 on 29 March 2027 in Europe/London, both to instants, and subtract them. If the answer is 1380 minutes, that day is 23 hours long and your code has to survive it. Run the same pair through your countdown's arithmetic and see whether it agrees.

The harness behind the table is about forty lines and runs on Node v26.12.0 with ICU 78.3 and tzdata 2026a, which is where those 2027 rules come from. If your code and mine disagree on the same date, one of us is resolving a repeated hour differently, and it's worth finding out which.

Limits

These numbers are calculated against the published rules, not observed on a machine whose clock changed at 01:00. Browsers bring their own ICU and tzdata and can disagree with Node for future dates, and governments do change rules with little notice, which is exactly why the recurrence rule says to store the zone and not the offset. Lord Howe Island shifts by 30 minutes, so a test that looks for an hour of error will miss it. Samoa skipping a calendar day in 2011 is a different failure mode and not covered. And none of this helps a timer that has to alert while the device is asleep, which is its own problem.