Exact vs calendar duration between two datetimes

Published: 2026-09-05

Why “31 days” and “1 month” are different answers, when to use a fixed millisecond span versus wall-clock years/months/days, and how LocalTools computes both locally.

Ask “how long between A and B?” and you can get two honest answers that disagree. Exact duration is a fixed count of milliseconds (split into 24-hour days, hours, minutes, seconds). Calendar duration walks local wall-clock fields—years, months, days—and borrows across uneven month lengths. Both are useful; mixing them causes off-by-one bugs in age checks, billing periods, and SLA reports.

LocalTools’ Date difference calculator shows both for the same start and end (local datetime-local pickers), plus signed millisecond totals and decimal day/hour/week totals—computed only in your browser (local-only).

Exact duration: fixed millisecond math

Exact breakdown starts from |end − start| in milliseconds, then divides by constants:

Unit Milliseconds
Day 86_400_000 (always 24 hours)
Hour 3_600_000
Minute 60_000
Second 1_000

So “1 day, 1 hour, 1 minute, 1 second” means exactly 90_061_000 ms (± ms remainder), not “tomorrow at the same clock time plus one hour.” DST does not change the length of an exact day in this model: an exact day is always 24×60×60×1000 ms of timeline.

Use exact duration when you care about:

  • Uptime, latency, or “elapsed since event” in logs
  • Countdowns and timers that must match Date.now() deltas
  • APIs that store Unix epoch (seconds vs milliseconds)

Signed rows (end − start) tell you whether the end is after or before the start; the human-readable exact breakdown usually uses the absolute span so labels stay non-negative.

Calendar duration: wall-clock years, months, days

Calendar breakdown subtracts local date/time fields (year, month, day, hour, …) and borrows when a lower field goes negative—same idea as subtracting mixed units by hand:

  • Negative hours → borrow one day and add 24 hours
  • Negative days → borrow one month; add the length of the previous calendar month in the end date’s zone
  • Negative months → borrow one year and add 12 months

Example intuition: Jan 15 12:00 → Feb 20 12:00 is 1 month and 5 days on the calendar, not “36 exact days” alone (those are related but different questions). February’s length, leap years, and “31st of the month” edge cases all live in this model.

Use calendar duration when you care about:

  • Ages (“turns 18 on this birthday”) and anniversary-style spans
  • “X years Y months” in HR or subscription copy
  • Civil deadlines phrased in months that ignore exact day counts

Calendar math is zone-sensitive: the tool uses this device’s local timezone for wall fields (same rules as a native datetime picker). For multi-city meetings, fix the instant first, then project—see IANA timezones, DST, and comparing the same instant.

When the two disagree (and that’s fine)

Situation Exact tends to say Calendar tends to say
Jan 31 → Mar 1 ~29–30 exact days (year-dependent) Often 1 month (+ leftover days after borrow)
Across a DST spring-forward Exact ms still grow at 1000/ms Wall clocks may skip an hour; field borrow still uses 24h hour units after day borrow
Same clock time tomorrow Exactly 1 day (24h) if no weirdness in ms 1 day, 0 hours if fields match

Neither answer is “wrong.” Product copy should name which model you mean: “within 30 days” (exact) vs “within one calendar month” (calendar).

Practical workflow

  1. Pick start and end as local wall times (or snap with Now).
  2. Read signed milliseconds / seconds when wiring code to epoch math.
  3. Copy the exact breakdown for logs and SLAs.
  4. Copy the calendar breakdown when humans expect years/months/days.
  5. Use decimal total days/hours/weeks when a spreadsheet wants a single float from |Δ|.

ISO strings in the output (UTC) help you paste into the ISO 8601 parser or Unix timestamp converter without retyping.

For legal deadlines, payroll, or contract language, confirm against an authoritative calendar—browser Date and tzdata are engineering aids, not courtroom proof.

Related tools on LocalTools

Related reading

All learn articles