Two correct answers to “how many days”
Monday to Friday is four days if you subtract, and five if you count the days involved.
Both are used in practice. A hotel charges for four nights between a Monday check-in and a Friday check-out. A five-day festival running Monday to Friday counts inclusively. Notice periods, holiday entitlement and court deadlines variously use one or the other, and statutes usually say which.
There is no correct convention, only a stated one. A tool that reports a day difference has to say which it is doing, and a contract that does not specify has an ambiguity in it worth roughly one day.
Before you read on
A subscription starts on 31 January and renews monthly. When is the second renewal?
28 February, then 28 March. Clamping is the usual convention, and it has a consequence worth knowing: adding a month twice is not the same as adding two months once. From 31 January, clamping gives 28 February and then 28 March; adding two months directly gives 31 March. Neither is a bug, and any system doing recurring monthly arithmetic has to pick one and stay consistent.
Months are not a length
Days, hours and seconds are durations: fixed quantities you can add. A month is not one. It is a calendar unit whose length depends on which month it is.
So “one month after 31 January” has no obvious answer. There is no 31 February. The conventions in use are:
- Clamp to the end of the month. 28 February, or 29 in a leap year. Most common.
- Overflow. 2 or 3 March, letting the day count run past the end.
Clamping is the usual choice and has a consequence worth knowing: adding a month twice can differ from adding two months once. From 31 January, clamping gives 28 February and then 28 March; adding two months directly gives 31 March. Neither is a bug, and any system doing recurring monthly arithmetic has to pick one and be consistent.
A recurring date schedule can instead keep 31 January as a permanent anchor: February gets its local month-end substitute, then March returns to the 31st. That is a third deliberate rule, not a correction to the two above. The defect is not choosing one of them; it is doing monthly arithmetic without saying which one the schedule means.
The same applies to years, where the only awkward date is 29 February, and it is awkward every time.
A day is not always 24 hours
Where daylight saving is observed, one day each year has 23 hours and another has 25. Multiply days by 86,400 seconds and you are correct for most of the year.
It gets worse than that at the edges. Time zones change their rules — the IANA database that records them is updated several times a year, mostly because some jurisdiction has decided something. Countries have changed offset outright, and a handful have skipped a calendar day when moving across the date line.
The practical rules that avoid nearly all of it:
- Work in UTC, and convert to local time only for display.
- Store an instant as an instant, not as a local wall-clock time with the zone implied.
- Never assume a fixed number of seconds in a day, month or year.
- Compute calendar differences on calendar dates, not by dividing elapsed milliseconds.
Which is why a timer must read the clock
A countdown that subtracts one second from its own total every time an interval fires will drift, and always in the same direction.
Intervals are not guaranteed. The browser throttles them heavily in a background tab, the machine can sleep and wake, and every tick is a little late rather than a little early. Each of those is a second the counter never subtracted, so a timer left running in another tab finishes visibly late.
The fix is not a more accurate interval. It is to record when the timer started and derive the remaining time from the real clock on every tick. Then throttling costs you a stale display for a moment rather than an accumulating error, and the timer is correct the instant the tab is looked at again.
That is a general principle for anything that tracks elapsed time: the interval is what prompts a redraw, and the clock is what the answer comes from.
Common questions
How many days are between Monday and Friday?
Four or five, and both are correct. Four is the difference — the number of nights between them. Five is the inclusive count of days involved, which is what a holiday booking or a hotel stay means. Neither is more right than the other, so any tool has to say which it is reporting, and any contract has to say which it means.
Why is adding a month ambiguous?
Because months have different lengths, so a month after 31 January has no obvious answer — 28 February, 2 March or 3 March, depending on the convention. Most systems clamp to the end of the target month, which means adding a month twice can differ from adding two months at once. Days are unambiguous; months are not.
Is a day always 24 hours?
No. In regions observing daylight saving, one day a year is 23 hours and another is 25. Some time zones have changed their offset entirely, and a few have skipped a calendar day. Computing a duration by multiplying days by 86,400 seconds is correct most of the time and wrong in ways that are hard to reproduce.
Why should a timer read the clock instead of counting ticks?
Because intervals are not reliable. A browser throttles timers in a background tab, the device sleeps, and each tick drifts slightly. A timer that counts its own ticks falls progressively behind real time, and the error grows the longer it runs. Reading the actual clock each time makes the display correct regardless of what happened to the intervals.