How to count down to a date and time
A countdown is one subtraction repeated every second: the target moment minus now. The hard parts are deciding which time zone the target is in and splitting a large number of seconds into readable units. Both are covered below.
Countdown
The core calculation
Computers store a moment in time as a count of milliseconds since 1 January 1970 at midnight UTC. This is often called a Unix timestamp. A countdown subtracts the current timestamp from the target timestamp:
Then it breaks the remaining time into units with whole-number division and remainders:
- seconds in total = floor(remaining ÷ 1,000)
- days = floor(total ÷ 86,400)
- hours = floor((total mod 86,400) ÷ 3,600)
- minutes = floor((total mod 3,600) ÷ 60)
- seconds = total mod 60
Worked example. remaining = 273,906,789 ms.
- Total seconds: 273,906
- Days: 273,906 ÷ 86,400 = 3, remainder 14,706
- Hours: 14,706 ÷ 3,600 = 4, remainder 306
- Minutes: 306 ÷ 60 = 5, remainder 6
- Result: 3 days, 4 hours, 5 minutes, 6 seconds
Time zones: the most common bug
“Midnight on 1 January” is a different moment in New York and in Los Angeles. A countdown needs a target that points to one exact instant. There are two ways to set it:
- Local target: “9:00 in whatever zone the viewer is in”. Each viewer reaches zero at a different instant. This suits personal goals, such as a birthday.
- Fixed target: “9:00 Eastern Time”. Everyone reaches zero together. This suits a live event or a product launch.
The calculator on this page reads your input as your own local time. For a shared event, write the time with its zone or as UTC, for example in ISO 8601 form: 2025-03-01T14:00:00Z, where Z means UTC.
Daylight saving time
On the days clocks change, a local day is 23 or 25 hours long. If you count “days” as blocks of 86,400 seconds, a countdown across a clock change can show an hour that seems to appear from nowhere. That is correct for elapsed time. If you need calendar days instead, compare the calendar dates, not the seconds.
Keeping a countdown accurate
- Recalculate from the clock each tick. Do not subtract one second per tick. Browsers slow timers in background tabs, and a counter that only subtracts drifts.
- Trust the device clock with care. A countdown in the browser uses the viewer’s system clock. If that clock is wrong, the countdown is wrong by the same amount.
- Decide what happens at zero. Show a message, or switch to counting up as “time since”.
Counting down in a spreadsheet
Subtract the current date-time from the target and format the result. In most spreadsheet apps, =B1-NOW() gives days as a decimal; multiply by 24 for hours. The value refreshes when the sheet recalculates, not every second.
FAQ
Why does my countdown differ from a friend’s?
Either the target is local time and you live in different zones, or one of your device clocks is off.
Does the countdown here keep running if I close the tab?
No. Nothing is stored. Open the page again and set the date.