timestampinfo.fr
Tools & documentation

THE TIME TOOLBOX

Timestamp Difference Calculator

Calculate the exact duration between two instants using a common unit.

Duration · 24-hour days—
Exact difference · seconds—

Compare two instants in your code

In JavaScript, compare two Date.parse() values after checking that neither is NaN. In Python, compare timezone-aware datetime objects. In PHP, compare two DateTimeImmutable objects created with explicit offsets.

For example, 2024-04-01T14:00:00+02:00 and 2024-04-01T12:00:00Z are equal as instants. Comparing their strings is not enough. See comparisons in Java.

Elapsed time, not calendar arithmetic

The tool subtracts the start from the end. A negative value means the end is earlier than the start. A day here is exactly 86,400 seconds.

Across a daylight saving transition, consecutive local midnights can be 23 or 25 hours apart. To calculate an interval, first convert each date to a timestamp with the correct offset.