How We Calculate Dates
Date math is full of small traps — time zones, leap years, daylight saving — so we document exactly how our date countdown works. No hidden rounding, no mystery numbers.
1. Everything uses your local time zone
When you pick “June 1, 9:00 AM,” we interpret that as 9:00 AM on June 1 in your device’s time zone — not UTC, and not anyone else’s. Both the target moment and the current moment are converted to the same absolute timestamp (milliseconds since January 1, 1970 UTC) before any subtraction happens, so the result is never off by a time-zone offset.
2. One subtraction, then whole units
The countdown is a single subtraction: target − now,
measured in milliseconds. We then break that difference into whole units, largest first:
- Days = the difference divided by 86,400,000 ms, rounded down.
- Hours = what’s left after whole days, divided by 3,600,000 ms, rounded down.
- Minutes = what’s left after whole hours, divided by 60,000 ms, rounded down.
- Seconds = what’s left after whole minutes, divided by 1,000 ms, rounded down.
Because we round each unit down, the display never shows a value it hasn’t fully reached — “2 days” means at least 48 hours remain, never 47.
3. Total days and weeks
The “total days” badge is the full millisecond difference divided by 86,400,000 and rounded down — an elapsed-time count, not a calendar-page count. Total weeks is total days divided by seven, also rounded down. Both derive from the same subtraction as the main display, so they can never disagree with it.
4. Leap years and daylight saving time
Leap years need no special handling because we work with absolute timestamps: February 29 is simply another 86,400,000-millisecond day. Daylight saving time is handled the same way — a 23-hour or 25-hour local day still maps to exact UTC timestamps, so a countdown across a DST change reflects the real elapsed time. This means a “one day” gap across a DST switch may show as 23 or 25 hours rather than exactly 24; that is the physically correct answer.
5. Past dates count up
If the target is in the past, the subtraction produces a negative number. We take the absolute value and label the result “time since the event,” so the same honest math tells you how long it has been instead of how long remains.
6. Staying accurate over time
The display refreshes once per second, but each refresh recomputes from the system clock rather than decrementing a counter. Even if your browser throttles the tab or your laptop sleeps and wakes, the next tick shows the correct time — the countdown can’t drift.