diff · years · weeks · days · live

Calculate the date difference

Days, weeks, months, years between any two dates — plus seconds, minutes, hours for the precise case. Sign tells you direction.

Date Difference
Days
—
primary
Weeks
—
÷7
Direction
—
Status
empty
pick both
AB
input · summary
Pick two dates to compare.
output · 7 units
—
Quick Start

How the diff is computed

The absolute difference in milliseconds, divided down by the constant length of each unit. Months and years are approximate because not all months are 30 days.

  1. 01

    Pick two dates

    Date A and date B — order doesn't matter, the diff is absolute.

    Parsing accepts ISO 8601, RFC 3339, RFC 2822, and Unix epoch seconds/milliseconds. The Date constructor handles the rest with browser-engine consistency.

    inputISO 8601RFC 3339epochlive
    A · timestampB · ISO
    2024-01-01
    2026-05-21
    loaded · ISO 8601zone · ready
  2. 02

    Sign tells direction

    "after" means B is later than A; "before" means earlier.

    All math runs in UTC internally to avoid DST landmines; presentation converts back to the user’s zone via Intl.DateTimeFormat.

    signUTC mathIntlDST-safelive
    B vs A · optionsafter · live
    B > A
    options applied · UTCDST-safe
  3. 03

    Seven units

    Years, months, weeks, days, hours, minutes, seconds — each is floor of the division.

    Output respects the chosen timezone offset (Z vs +05:30) and pads digits per ISO conventions so sorts stay chronological.

    unitsoffsetzone-awaresortablepadded
    units · computed7 · ready
    y · w · d · s
    computed · instantsortable
  4. 04

    Copy any unit

    Click a row to copy that number to clipboard.

    Copy writes via the Async Clipboard API; nothing pings a time server — the browser’s clock is the only oracle.

    copyclipboardno oracledeterministicclient-side
    ✓ · copiedready · done
    ✓ Copied
    shipped · ready to shipsuccess
Pro tips

Time math without DST landmines

Always store UTC

Convert to local for display only. UTC storage avoids DST jumps and timezone drift in databases.

Watch leap seconds

POSIX time doesn’t count leap seconds; some systems do. Don’t use timestamps for sub-second precision across boundaries.

Prefer Temporal eventually

The Date API has many quirks. Temporal is shipping in modern engines and handles zones correctly.

Cron is timezone-tricky

Cron expressions run in the daemon’s local zone unless told otherwise. Pin a TZ explicitly for predictable runs.

ISO 8601 sorts naturally

YYYY-MM-DDTHH:mm:ss sorts correctly as a string. Don’t use US-style MM/DD/YYYY for anything machine-readable.

Beware Y2K38

Signed 32-bit Unix timestamps overflow in 2038. Use 64-bit storage end-to-end for long-lived systems.

Use Cases

When to use date diff

Tenure, anniversaries, project age.

Tenure

Years of service since a hire date. Math runs in UTC under the hood to dodge DST jumps — local time is only for display. That means scheduling logic and date diffs survive March / November fall-back without the classic off-by-one-hour bug.

DST-safe

Project age

How long ago was the initial commit? Browser clock is the only source — no external time server, no privacy leak, no rate limit. Pair with NTP-synced server time for high-accuracy use cases, but for human-scale work the browser clock is plenty.

UTC-correct

Anniversary

Days until a milestone — wedding, birthday, launch. ISO 8601 output sorts naturally as strings, perfect for filenames (report-2026-01-15.pdf) and log lines that need chronological ordering without parsing. Drop into S3 keys for free time-bucketing.

ISO-sortable

Subscription length

Customer lifetime in months / years. Pairs cleanly with cron, scheduled tasks, and timestamped log analysis. The tool's output drops directly into APScheduler, Linux cron, or GitHub Actions schedule expressions without re-formatting.

spec-grade

Project planning

Weeks remaining to a launch date. Output respects the chosen timezone offset (Z vs +05:30) so REST APIs and database TIMESTAMP WITH TIME ZONE columns round-trip cleanly. No ambiguity between "noon UTC" and "noon local".

zone-aware

Historical events

How long ago was a famous date? Confirms the difference between epoch seconds (10 digits) and milliseconds (13 digits) before you commit code that mis-multiplies by 1000 — a classic bug in cross-language time handling.

epoch-accurate
FAQ

Frequently asked questions

Months vary (28-31 days) and years vary (365/366). We use 30.4375 days/month and 365.25 days/year — the long-run averages.
Use the date-add-subtract tool — calendar-month arithmetic differs from average-month division.
Date picker uses local midnight. DST transitions don't affect the day count, only hour totals.
We return absolute value plus a sign label so the rows are always positive numbers.
No — the math runs locally in your browser tab.
Suggest a tool

Something missing?

Tell us what you need. We ship the top requests every two weeks.

Sent straight to the maintainers · no account needed
47 in queue·8 shipped this month
Request queued. Thanks!