Count hours calculator
From 10:00 PM to 6:00 AM is 8 hours: type two clock times and get the hours between them, even when the span crosses midnight. Half hours come out as a decimal such as 8.5. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Start time
- 09:00 AM
- End time
- 05:00 PM
- Start
- 09:00
- End
- 17:00
- Hours
- 8
- Total minutes
- 480
How many hours is it from 9:00 AM to 5:00 PM? How many hours does a night shift last from 10:00 PM until 6:00 AM? A count-hours calculator answers that everyday question with a single elapsed-hour figure, including a half hour when the interval is not a whole number of hours. You type two times of day — twelve-hour AM/PM or twenty-four-hour clock — and the tool returns the hours between them. Malformed strings such as 25:00 or noonish are rejected instead of being guessed. There is no network call, no system clock, and no randomness: only seconds from midnight and a single optional plus-twenty-four-hour wrap when the end sits earlier on the face than the start.
How two times of day become a single hour count
A time of day is a position on a circular civil day, not a calendar date and not a duration you add to something else. Nine in the morning is thirty-two thousand four hundred seconds after midnight; five in the afternoon is sixty-one thousand two hundred seconds after midnight. Subtracting those second-from-midnight counts and dividing by three thousand six hundred yields the hour count people actually ask for: eight hours from 9:00 AM to 5:00 PM.
When the end includes a half hour, the same arithmetic returns a decimal such as 8.5 rather than a clock-style pair of hours and leftover minutes, because the search that lands here is “how many hours”, not “how many hours and minutes”. When the end is earlier than the start — a night shift from ten at night to six in the morning, a parking stay that crosses midnight, a sleep window from eleven to seven — a naive subtraction goes negative.
The count-hours rule then adds twenty-four hours, the length of one civil day, so the interval wraps once past midnight and stays in the closed range from zero hours through just under twenty-four hours. Equal start and end yield zero hours, not a full day, because the two readings name the same instant on the face.
Input contract, twelve-hour AM/PM, and malformed times
Each must be a valid time of day. Twenty-four-hour form is H:MM, HH:MM, or the same with seconds (H:MM:SS / HH:MM:SS), with the hour an integer from zero through twenty-three and the minute and second from zero through fifty-nine. Twelve-hour form accepts a meridian: 9:00 AM, 9am, 5:30 PM, 5:30 p.m., and hour-only strings such as 9am when a meridian is present.
Twelve AM is midnight and twelve PM is noon; an hour outside one through twelve with AM or PM is malformed. Leading zeros on the hour are optional. A missing field, an empty string after trim, or a non-string value also fails, because this contract is a time-of-day format, not a duration adder and not a free-text parser.
Invalid input is not billed.
Where a count-hours calculator earns its keep
People reach for a count-hours calculator whenever two wall-clock readings must become a single hour figure they can type into a timesheet, a invoice line, or a study log. Shift supervisors convert a 9:00 AM start and a 5:00 PM end into eight hours without doing the twelve-hour arithmetic by hand. Payroll and freelance invoices want decimal hours — eight point five, not eight hours thirty minutes — because most billing systems multiply an hourly rate by that one number.
Parking and garage desks quote elapsed stay from entry to exit, including an overnight wrap when a car leaves after midnight. Parents and coaches time a practice that begins at four and ends at five thirty. Nurses, dispatchers, and hotel night desks compute an interval that starts late and ends early the next morning.
Students learning elapsed time check that 09:00 to 17:30 is eight and a half hours instead of a borrow error on paper. Because the tool refuses illegal hours and guessed words, it also doubles as a time-of-day format validator for intake forms that must not accept 25:00 or noonish. Pair this page with a date-difference or countdown tool if you also need whole days between calendar dates, or with an add-time calculator if you need to sum two durations rather than subtract two clock faces.
What you can do with it
Workday and timesheet hour totals
Turn a 9:00 AM start and a 5:00 PM end into eight hours for a timesheet that wants one hour count, not a clock-style hours-and-minutes split.
Decimal hours for invoices and payroll
Convert 09:00 to 17:30 into 8.5 hours so an hourly rate multiplies against a single number instead of leftover minutes.
Overnight shifts and parking stays
Count hours from 10:00 PM to 6:00 AM as eight hours with overnight true, including a wrap past midnight when the end is earlier than the start.
FAQ
Does 9:00 AM to 5:00 PM count as eight hours?
Yes. Nine in the morning to five in the afternoon is eight hours. A half-hour end such as 17:30 returns 8.5 so billing systems can multiply a rate by one figure.
What happens if the end time is earlier than the start time?
The interval is treated as wrapping once past midnight. From 10:00 PM to 6:00 AM the result is 8 hours and overnight is true. Equal times yield zero, not a full day.
Which time formats are accepted, and what is malformed?
24-hour H:MM, HH:MM, or HH:MM:SS, and 12-hour times with AM/PM such as 9:00 AM or 9am.
Why do I get 8.5 hours instead of 8 hours and 30 minutes?
Because the tool answers how many hours, so a half hour is shown as a decimal. Multiply the decimal part by 60 if you need minutes: 0.5 of an hour is 30 minutes.
What do I get if the start and end times are the same?
Zero hours, not a full day. Two equal readings name the same moment on the clock, so the tool does not assume you meant a 24-hour stay.
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/count-hours \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"start_time":"09:00 AM","end_time":"05:00 PM"}'const res = await fetch("https://api.kit.forhosting.com/life/count-hours", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"start_time": "09:00 AM",
"end_time": "05:00 PM"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/life/count-hours",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"start_time": "09:00 AM",
"end_time": "05:00 PM"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/life/count-hours", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"start_time":"09:00 AM","end_time":"05:00 PM"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"start_time":"09:00 AM","end_time":"05:00 PM"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/life/count-hours", 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_time": "09:00 AM",
"end_time": "05:00 PM"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "life.count_hours",
"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
How two times of day become a single hour count
The algorithm never consults the system clock, never calls a network service, and never uses randomness, so the same pair of time strings always produces the same hours, total_minutes, overnight flag, and pretty string.
Input contract, twelve-hour AM/PM, and malformed times
The request body carries two required strings: start_time and end_time. ISO datetimes that include a calendar date, bare numbers without a meridian such as 9, and out-of-range values such as 25:00 or 12:60 all fail with invalid_input and name the offending field. Aliases start, from, and begin are accepted for start_time; aliases end, to, until, and stop are accepted for end_time so forms and scripts can use the name they already have. On success the response echoes both times normalized to twenty-four-hour HH:MM (or HH:MM:SS when seconds were supplied), the elapsed hours as a number, total_minutes as the exact minute count, overnight as a boolean that is true only when the end was earlier than the start, a pretty string such as 8 hours or 8.5 hours, and a short formula you can print next to the answer. Successful API calls use the published $0.002 base price.
Where a count-hours 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
How do I count the hours between two times of day?
Send start_time and end_time as 12-hour AM/PM or 24-hour strings. The API converts each to seconds from midnight, subtracts, adds 24 hours if the end is earlier, and returns hours as a single number.
What does the count-hours calculator cost?
The browser tool is free. API requests use prepaid balance at $0.002 per successful call; invalid input is not billed.