Timestamp Diff — Calculate Duration Between Two Dates or Timestamps
Calculate the exact duration between two dates or Unix timestamps. Output in seconds, minutes, hours, days, weeks, months, and years — all in browser.
Computing the duration between two points in time is one of the most common date operations and one of the most mistake-prone. The days between January 31 and March 1 depend on whether the year is a leap year (one day difference). The hours between 1:30 AM and 3:30 AM on a DST transition day can be one hour or three hours depending on which direction the clock moved. A duration expressed as “3 months” is ambiguous — it means different things for February, for months of 30 vs 31 days, and for partial months at either end. The Timestamp Diff tool handles the calendar arithmetic correctly and presents the result broken down into every useful unit: the total seconds, the minutes and remaining seconds, the hours and remaining minutes, all the way up to years.
The tool accepts any date format that the browser’s built-in parser understands — ISO 8601 with and without timezone offsets, RFC 2822 for email headers, Unix timestamps in seconds or milliseconds, and natural-language dates in the user’s locale. The output includes the ISO 8601 duration string (P3DT6H30M for 3 days, 6 hours, 30 minutes) which is the standard format for expressing durations in XML Schema, JSON Schema, and Java’s java.time.Duration class. The companion Epoch-to-Date and Date-to-Epoch tools on this site handle the conversion between timestamps and human-readable dates, so the full date-manipulation workflow — convert, compare, compute duration — is covered.
How to use
Enter the two timestamps
Enter two dates or Unix timestamps. The inputs accept ISO 8601 dates (2026-06-15T14:30:00Z), Unix timestamps in seconds or milliseconds, and natural formats like 'June 15, 2026 2:30 PM'.
Choose the output units
Select the primary output unit — seconds, minutes, hours, days, weeks, months, or years. The detailed breakdown shows all units simultaneously: the difference expressed as each unit plus the remainder.
Copy the result
Copy the duration as a single number, a human-readable breakdown, or an ISO 8601 duration string (P3DT6H30M). The ISO format is compatible with XML schema, JSON Schema, and Java's Duration class.
Frequently asked
Does it account for leap years and daylight saving?
Calculations in days or larger units use calendar-aware arithmetic that accounts for leap years (February 29) and months of different lengths. Calculations in seconds or smaller are absolute wall-clock differences. DST transitions are not handled — if a timestamp crosses a DST boundary, the wall-clock difference and the elapsed-time difference may not match.
What is the difference between Unix seconds and Unix milliseconds?
Unix timestamps in seconds are 10-digit numbers (e.g., 1718400000). Unix timestamps in milliseconds are 13-digit numbers (e.g., 1718400000000). The tool auto-detects the magnitude and converts both formats. If you paste a 10-digit number, it is treated as seconds.
Can it compute the difference between a date and 'now'?
Yes — leave one field empty (or click 'now') to use the current date and time in your browser's timezone. This is useful for calculating age from a birthdate, tenure from a start date, or time remaining until a deadline.
What timezone does the calculation use?
UTC by default for ISO 8601 inputs with a Z suffix or no timezone offset. For local dates and times without a timezone, the browser's local timezone is used. Timestamps with explicit offsets (+05:30, -08:00) are respected.
Limitations
- No recurring schedule calculationThe tool computes a single duration between two fixed points. For recurring schedules (every Monday, every 2 weeks), use a cron expression parser or a dedicated scheduling tool.
- No business-day awarenessThe output is calendar days, not business days. For business-day calculations (excluding weekends and holidays), add the holiday exclusions manually or use a dedicated library.
- Month and year differences are approximate"3 months" between January 31 and April 30 is not the same as between January 30 and April 30. Month-based output rounds to the nearest whole month; the days-and-months breakdown shows the exact remainder.
Platform notes
- macOS
- The built-in Calculator app has a date-difference mode. The browser tool adds the breakdown into all units simultaneously and the ISO 8601 duration output for programmatic use.
- Linux
- The `datediff` command (from `dateutils`) computes date differences. The browser tool adds auto-detection of timestamp formats and the all-units breakdown in one view.
- Web
- Runs entirely in the browser. Timestamps are processed locally — no dates are transmitted to a server. Useful for calculating durations for internal project timelines.