Timestamp Difference
Enter two Unix timestamps to get the time between them in milliseconds, seconds, minutes, hours and days.
Calculate the difference between two timestamps
Enter two Unix timestamps and the calculator returns the gap in milliseconds, seconds, minutes, hours and days, plus a human-readable duration such as 2 days 4 hours 12 minutes 30 seconds. The result is always a positive amount, with a sentence telling you which timestamp comes first.
Common uses
Measure how long a job ran from two log lines, check how long a session or token lived, work out the time left until an expiry, or find the age of a record. Each field has its own Unit setting, so you can compare a value in seconds with a value in milliseconds.
Want the background? Read our comprehensive guide: What Is Unix Time?.
How to use this tool
- Enter Timestamp A and Timestamp B, or select Use current time on either field.
- Set the unit of each timestamp, or leave both on Auto.
- Select Calculate difference.
- Read the totals and the human-readable duration. Swap A and B to reverse the direction.
Examples
Timestamp B is later than timestamp A in this example.
Two days, four hours, twelve minutes and thirty seconds
A = 1790000000, B = 1790187950 (seconds)
- Human-readable
- 2 days 4 hours 12 minutes 30 seconds
- Seconds
- 187950
- Hours
- 52.208333
Timestamps in different units
A = 1790000000 (seconds), B = 1790000000500 (milliseconds)
- Human-readable
- 500 milliseconds
Each timestamp has its own unit setting, and Auto detects each one separately.
A full day apart
A = 1790000000, B = 1790086400 (seconds)
- Human-readable
- 1 day
- Hours
- 24
Frequently Asked Questions
How do I calculate the difference between two timestamps in code?
Are months and years included?
Can I mix seconds and milliseconds?
Does daylight saving time change the result?
Related tools
- Unix Timestamp ConverterTurn a Unix timestamp into UTC, local time and ISO 8601.
- Epoch ConverterSee epoch seconds and milliseconds side by side, with UTC and local time.
- Timezone ConverterConvert time between zones and compare cities side by side.
- Date to TimestampConvert a date, time and time zone into a Unix timestamp.