Calculate the exact difference between two Unix timestamps, ISO 8601 dates, or human-readable date/time values. See results in days, hours, minutes, seconds, and milliseconds. Supports both 10-digit (seconds) and 13-digit (milliseconds) epoch timestamps. Perfect for debugging log files, measuring API response times, and calculating durations. All computation runs in your browser.
Time is the single most error-prone primitive in software. Time zones, daylight saving, leap seconds, leap years, locale calendars, and the inconsistent way languages handle "now" all combine into a category of bugs that show up at 02:00 on the second Sunday in March and again on the first Sunday in November. This guide is the working reference for the two formats you actually need (Unix epoch and ISO 8601), the duration calculations that bite teams, and the language-by-language code that does it correctly.
Unix time is the number of seconds elapsed since 1970-01-01T00:00:00 UTC (the "epoch"). It is the universal time format in databases, APIs, log files, and inter-service messaging because it is:
The two common widths:
Date.now(), Java's System.currentTimeMillis(), Kafka.timestamp(6), Go's time.Now().UnixNano().A 32-bit signed integer storing seconds-since-1970 overflows on 2038-01-19T03:14:07 UTC. After that moment, naive 32-bit Unix time wraps to -2,147,483,648 (December 1901). This affects:
DATETIME columns prior to 5.6.Modern systems use 64-bit time_t, which gives ~292 billion years of headroom. If you ship to embedded systems or maintain legacy software, audit for 32-bit time storage now — the failure mode is silent and starts hitting 30-year mortgages and 20-year insurance contracts already.
ISO 8601 is the international standard for date/time representation. The canonical forms:
2026-05-02 — date only.2026-05-02T14:30:00Z — full datetime in UTC (the Z means "Zulu", i.e. UTC).2026-05-02T14:30:00+05:00 — full datetime with explicit offset.2026-05-02T14:30:00.123Z — millisecond precision.P1Y2M10DT2H30M — duration: 1 year, 2 months, 10 days, 2 hours, 30 minutes.Always include the timezone marker (Z or ±HH:MM). A bare 2026-05-02T14:30:00 is ambiguous — different parsers interpret it as UTC vs local vs throw an error.
Duration calculations work cleanly in two regimes:
The conversion table for fixed units:
| Unit | Seconds | Milliseconds |
|---|---|---|
| Second | 1 | 1 000 |
| Minute | 60 | 60 000 |
| Hour | 3 600 | 3 600 000 |
| Day | 86 400 | 86 400 000 |
| Week | 604 800 | 604 800 000 |
| 30-day month (approx) | 2 592 000 | 2 592 000 000 |
| 365-day year (approx) | 31 536 000 | 31 536 000 000 |
const a = new Date('2026-05-02T09:00:00Z');
const b = new Date('2026-05-02T11:30:00Z');
const seconds = (b - a) / 1000; // 9000
const minutes = seconds / 60; // 150
const hours = minutes / 60; // 2.5from datetime import datetime, timezone
a = datetime(2026, 5, 2, 9, 0, tzinfo=timezone.utc)
b = datetime(2026, 5, 2, 11, 30, tzinfo=timezone.utc)
delta = b - a # timedelta(seconds=9000)
print(delta.total_seconds()) # 9000.0import "time"
a, _ := time.Parse(time.RFC3339, "2026-05-02T09:00:00Z")
b, _ := time.Parse(time.RFC3339, "2026-05-02T11:30:00Z")
diff := b.Sub(a) // 2h30m0s
seconds := diff.Seconds() // 9000import java.time.*;
Instant a = Instant.parse("2026-05-02T09:00:00Z");
Instant b = Instant.parse("2026-05-02T11:30:00Z");
Duration d = Duration.between(a, b); // PT2H30M
long secs = d.getSeconds();use chrono::{DateTime, Utc};
let a: DateTime<Utc> = "2026-05-02T09:00:00Z".parse().unwrap();
let b: DateTime<Utc> = "2026-05-02T11:30:00Z".parse().unwrap();
let d = b - a; // Duration
let secs = d.num_seconds(); // 9000SELECT EXTRACT(EPOCH FROM ('2026-05-02 11:30:00+00'::timestamptz
- '2026-05-02 09:00:00+00'::timestamptz))
AS seconds_diff; -- 9000new Date('2026-05-02') parses as midnight UTC; new Date(2026, 4, 2) parses as midnight local time. Different result, no warning.cron can skip a job (during spring-forward) or run it twice (during fall-back). Schedulers that respect named time zones (kubernetes CronJob with spec.timeZone) avoid this.America/New_York, not EST.CLOCK_MONOTONIC.request_start and response_end timestamps; diff gives latency.created_at with now(); if greater than TTL, evict.exp claim with current time.1714660000 (seconds) from 1714660000000 (ms) without converting gives a meaningless result.timestamptz in Postgres, DATETIME WITH TIME ZONE, or store ISO 8601 with explicit offset.Date.parse() on partially-formed strings. Browsers vary in tolerance; Safari is stricter than Chrome. Always pass full ISO 8601.Date.now() for benchmarks. The system clock can jump backward (NTP correction). For elapsed-time measurement use performance.now() in browsers or CLOCK_MONOTONIC on Linux.diff = timestamp2 - timestamp1. Then convert: divide by 86,400 for days, 3,600 for hours, 60 for minutes. This tool does the conversion automatically and shows results in all units simultaneously.2026-03-20T14:30:00Z), and common date strings (March 20, 2026, 2026/03/20). If a value looks like a number, it's treated as a timestamp; otherwise it's parsed as a date string.Z suffix (e.g., 2026-03-20T09:00:00Z).All tools run in your browser, no signup required, nothing sent to a server.