Elapsed time calculator
From 09:30 on 10 March 2024 to 14:45:30 on 12 March 2024, 2 days, 5 hours, 15 minutes and 30 seconds passed. Enter two timestamps with their dates and get the full elapsed time, never a negative one. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Start
- 2024-03-10T09:30:00Z
- End
- 2024-03-12T14:45:30Z
- Start
- 2024-03-10T09:30:00.000Z
- End
- 2024-03-12T14:45:30.000Z
- Days
- 2
- Hours
- 5
How much time passed between two timestamps? An elapsed-time calculator answers that everyday question with a full duration, not just whole calendar days and not just the hours on a single clock face. You give a start timestamp and an end timestamp — ISO-8601 datetimes such as 2024-03-10T09:30:00Z, date-only days treated as midnight UTC, or Unix seconds — and the tool returns the elapsed days, hours, minutes, seconds, and milliseconds. There is no network call, no system clock, and no randomness: only civil-calendar conversion to UTC milliseconds and a subtraction that refuses to go backwards.
How two timestamps become days, hours, minutes, and seconds
A timestamp names an instant on the civil timeline, not a position on a twelve-hour or twenty-four-hour clock face and not a duration you already measured. 2024-03-10T09:30:00Z is a single UTC instant; 2024-03-12T14:45:30Z is a later instant. The elapsed-time rule converts each instant to milliseconds since the Unix epoch using proleptic Gregorian calendar arithmetic — leap years, month lengths, and timezone offsets included — then subtracts start from end.
The non-negative remainder is split by successive integer division: eighty-six million four hundred thousand milliseconds make a day, three million six hundred thousand make an hour, sixty thousand make a minute, and one thousand make a second. What is left is the millisecond residue. Equal timestamps yield zero elapsed time, not a full day, because the two readings name the same instant.
Date-only values such as 2024-01-01 are treated as midnight UTC so a week from the first to the eighth is exactly seven days. Numeric Unix seconds are multiplied by one thousand; values whose absolute magnitude is at least one trillion are treated as milliseconds already, which is how log exporters and browsers usually stamp events.
Where an elapsed-time calculator earns its keep
People reach for an elapsed-time calculator whenever two recorded instants must become a length that a human can read and a script can store. Incident commanders convert a start timestamp and an end timestamp into days and hours for an SLA window. Product and support teams measure how long a session, a job, or a deployment lasted from the first log line to the last.
Payroll and timesheet tools that already store clock-in and clock-out as datetimes need a duration, not a calendar-day count and not a same-day clock-face wrap. Students learning elapsed time check that 09:30 on the tenth to 14:45:30 on the twelfth is two days five hours fifteen minutes thirty seconds instead of a borrow error on paper.
Pair this page with a clock-duration tool if you only have two times of day and no date, with a days-between tool if you only want whole calendar days, or with a humanize-duration formatter if you already have a number of seconds and only need English wording. Because the tool refuses an inverted interval, it also doubles as a timestamp-order validator for intake forms that must not accept an end before a start.
What you can do with it
Incident and SLA windows
Turn a start timestamp and an end timestamp from an incident log into days, hours, and minutes for an SLA write-up that must not accept an inverted interval.
Shift and session length from datetimes
Compute how long a shift, a meeting, or a recorded session lasted when both ends are stored as ISO datetimes or Unix seconds, including multi-day spans.
Classroom and log elapsed-time checks
Let students and scripts verify that 2024-03-10T09:30:00Z to 2024-03-12T14:45:30Z is 2 days 5 hours 15 minutes 30 seconds, and that an earlier end is rejected.
FAQ
How do I calculate elapsed time between two timestamps?
Send start and end as ISO-8601 datetimes (or date-only midnight UTC) or as Unix seconds.
What happens if the end timestamp precedes the start?
Elapsed time requires the end to be at or after the start; the calculator does not wrap past midnight and does not return a negative duration.
Which timestamp formats are accepted?
ISO-8601 YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss with optional fraction and Z or ±HH:mm, and Unix seconds (or milliseconds when the absolute value is at least 1e12). Clock-only strings such as 09:30 without a date are rejected.
How is this different from a clock duration or days-between calculator?
Clock duration subtracts two times of day on a circular clock and can wrap midnight. Days between counts whole calendar dates. This page measures the full duration between two absolute timestamps.
Can I get the whole duration in seconds?
Yes. Besides days, hours, minutes and seconds, you get the total in seconds: from 09:30 on 10 March 2024 to 14:45:30 on 12 March 2024 that is 191730 seconds.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/life/elapsed-time \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"start":"2024-03-10T09:30:00Z","end":"2024-03-12T14:45:30Z"}'const res = await fetch("https://api.kit.forhosting.com/life/elapsed-time", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"start": "2024-03-10T09:30:00Z",
"end": "2024-03-12T14:45:30Z"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/life/elapsed-time",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"start": "2024-03-10T09:30:00Z",
"end": "2024-03-12T14:45:30Z"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/life/elapsed-time", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"start":"2024-03-10T09:30:00Z","end":"2024-03-12T14:45:30Z"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"start":"2024-03-10T09:30:00Z","end":"2024-03-12T14:45:30Z"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/life/elapsed-time", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"start": "2024-03-10T09:30:00Z",
"end": "2024-03-12T14:45:30Z"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "life.elapsed_time",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
If the end precedes the start, the request is rejected instead of returning a negative duration that a timesheet or a log would silently misread.
How two timestamps become days, hours, minutes, and seconds
The algorithm never consults the system clock, never calls a network service, and never uses randomness, so the same pair of timestamps always produces the same days, hours, minutes, seconds, total_seconds, pretty phrase, and compact string.
Input contract, accepted formats, and the end-before-start error
Each may be an ISO-8601 date in YYYY-MM-DD form, an ISO-8601 datetime with an optional fractional second and a Z or plus-or-minus HH:mm offset, or a Unix timestamp as a number or numeric string. Leading and trailing spaces are trimmed. Invalid input is not billed. The request body carries two required fields: start and end. Aliases start_time, start_timestamp, from, and begin are accepted for start; aliases end_time, end_timestamp, to, until, and stop are accepted for end so forms and scripts can keep the names they already have. A missing field, an empty string after trim, a non-string non-number, an impossible civil day such as 2024-02-30, an hour outside zero through twenty-three, or a string that is neither ISO nor numeric fails with invalid_input and names the offending field. When the parsed end instant is earlier than the parsed start instant the task also fails, with a message that the end precedes the start: this calculator will not invent a wrap across midnight or a signed negative duration. On success the response echoes both timestamps normalized to UTC ISO-8601 with millisecond precision, the broken-down days, hours, minutes, seconds, and milliseconds, total_seconds and total_milliseconds as exact counts, a pretty English phrase such as 2 days 5 hours 15 minutes 30 seconds, a compact token such as 2d 5h 15m 30s, and a short formula you can print next to the answer. Successful API calls use the published $0.002 base price.
Where an elapsed-time calculator earns its keep
That keeps latency at a handful of arithmetic operations and keeps the cost model honest at $0.002 per successful API request, while failed validation never consumes prepaid balance.
Technical questions
What does the elapsed time calculator cost?
The browser tool is free. API requests use prepaid balance at $0.002 per successful call; invalid input is not billed.