Countdown Timer — Days, Hours & Minutes Until Any Date
Pick any future date and watch a live countdown tick down to the second. Add an event title, then copy a sharable link that opens the same countdown on any device. Runs in your browser, no signup, no ads.
How it works
The timer answers two questions at once: how long until the target, and how that gap reads as a calendar duration like "7 months, 20 days, 12 hours". Both use the half-open interval [now, target), so the moment the clock reaches the target the countdown switches to elapsed mode and starts counting up.
For the total counts (days, hours, minutes, seconds), the algorithm subtracts the two timestamps and divides the millisecond delta by the appropriate constant. This is the raw wall-clock difference and honestly reports DST shifts when they happen — a day that contains a DST transition counts as 23 or 25 hours instead of being silently normalised to 24.
For the calendar-aware Y/M/D + H/M/S breakdown, the algorithm follows the date-fns intervalToDuration anniversary rule. Given a start S and target T:
- Compute raw month gap
M = (T.year − S.year) × 12 + (T.month − S.month). - If the target's day-of-month hasn't reached the start day yet (
T.day < S.day), or the days match but the time-of-day hasn't caught up, subtract one fromM. - Split into years and months:
years = ⌊M / 12⌋,months = M mod 12. - Build an anchor date
S + M months, clamping the day-of-month to the last day of the resulting month so 31 Jan + 1 month becomes 28 Feb in a non-leap year, not 3 Mar. - Compute the residual milliseconds from the anchor to
Tand split greedily into days, hours, minutes, and seconds. The breakdown reconciles exactly:S + Y years + M months + D days + H:Mn:S = T.
To guard against single-algorithm bugs, the total-seconds figure is cross-checked against a second implementation that uses raw millisecond division, and the calendar breakdown is verified by reconstructing the target through addition. Both checks must pass before the "cross-checked · 2 algorithms" badge appears in the live header.
Share links encode the target as an ISO 8601 UTC timestamp and the title via RFC 3986 percent-encoding, so a link copied from Colombo opens with the same instant in mind from Toronto — the browser then renders it in the visitor's local time zone for the countdown.
Worked examples
Frequently asked questions
Sources & references
- ECMA-262 — JavaScript Date object specification
- date-fns — intervalToDuration anniversary rule
- ISO 8601 — duration format (PnYnMnDTnHnMnS)
- Gregorian calendar — leap-year rule (Wikipedia)
- RFC 3986 — percent-encoding for share-link parameters
Algorithm and worked examples last cross-checked on 2026-05-11. The calendar arithmetic is stable, so this page is reviewed annually rather than on a fixed schedule.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.