ForHosting KIT · Developer Utilities

Gap between two time intervals

The gap between two time intervals calculator measures the elapsed time separating two explicit ISO datetime ranges.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Give each interval a start and end with a UTC designator or numeric offset, and the result is normalized to UTC before comparison. The calculator returns zero when the ranges overlap or meet at a boundary, so it works cleanly for schedules, logs, reservations, and timeline validation. Along with milliseconds and seconds, it provides an ISO 8601 duration and identifies which interval comes first.

Enter complete intervals with explicit offsets

Provide four values: the start and end of the first interval, followed by the start and end of the second. Every value must be a complete ISO 8601 datetime such as <code>2026-07-25T09:00:00Z</code> or <code>2026-07-25T12:00:00+01:00</code>. The explicit zone is essential because a local clock reading alone does not identify one instant. Each start must be no later than its matching end, but the first interval does not have to occur first chronologically. Fractional seconds are supported with one, two, or three digits. Calendar-only dates, zone names, leap seconds, and omitted offsets are rejected instead of being guessed. This strict input contract makes the result portable across servers and browsers. It also prevents daylight-saving settings on the machine running the calculation from changing the answer. If your source stores named zones, resolve those values to explicit offsets before calling this capability, using the correct offset for each endpoint's actual date.

Understand how the UTC gap is calculated

Each endpoint is converted through calendar arithmetic to a UTC millisecond position. The calculator then checks both possible chronological arrangements. When the first interval ends before the second begins, the gap is the second start minus the first end. When the second interval ends before the first begins, the calculation is reversed. In every other case the ranges overlap or touch, and the gap is exactly zero. Touching includes equality at one boundary: an interval ending at 10:00 and another beginning at 10:00 has no elapsed time between them. Offsets are normalized before these comparisons, so 12:00 at +01:00 is treated as the same instant as 11:00Z. The response includes the gap in milliseconds, the same quantity in seconds, a machine-friendly ISO 8601 duration, and an order label. The method uses no current clock, locale, network service, or runtime date parser, making repeated calls deterministic.

Use the result safely in scheduling workflows

The zero-or-positive result is useful when a workflow cares about idle time rather than total span. A booking system can test the cleanup window between reservations; an observability pipeline can measure silence between incidents; and an import validator can detect whether reported operating periods conflict. Check the order label when downstream logic needs to know which interval came first. Treat <code>overlap_or_touch</code> as a deliberate combined state: the numerical gap is zero in both situations, because neither leaves elapsed time between the ranges. If you need overlap length, calendar-aware business hours, or a distinction between touching and intersecting interiors, use a dedicated calculation rather than deriving it from this gap alone. The browser runner executes the same pure solver as the API, which makes it suitable for manual verification before automation. API requests use the published base price of $0.002. Preserve the returned millisecond value when exact subsecond comparisons matter, and use the ISO duration for interchange or display formatting.

Verify reservation buffers

Measure the exact idle window between bookings after normalizing their explicit timezone offsets.

Analyze event timelines

Calculate the silence between two logged incidents even when their systems record different UTC offsets.

Validate schedule separation

Confirm that two planned operating windows have enough elapsed time between them, regardless of input order.

What happens when the intervals overlap?

The gap is zero and the order is overlap_or_touch, because there is no elapsed time separating the ranges.

What happens when one interval ends exactly as the other begins?

They touch, so the returned gap is exactly zero.

Are different timezone offsets supported?

Yes. Every endpoint is normalized from its explicit Z or numeric offset to UTC before comparison.

Can I omit the timezone offset?

No. An explicit offset is required so the calculation never depends on a server, browser, or local timezone setting.

How precise is the result?

Inputs and outputs support millisecond precision, with the gap also returned in seconds and as an ISO 8601 duration.

What does an API request cost?

The published base price is $0.002 per request, and the same deterministic calculation is available in the browser runner.

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.

POSThttps://api.kit.forhosting.com/date/intervals-gap

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.

curl -X POST https://api.kit.forhosting.com/date/intervals-gap \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"first_start":"2026-07-25T09:00:00Z","first_end":"2026-07-25T10:30:00Z","second_start":"2026-07-25T12:00:00+01:00","second_end":"2026-07-25T13:00:00+01:00"}'
{
  "first_start": "2026-07-25T09:00:00Z",
  "first_end": "2026-07-25T10:30:00Z",
  "second_start": "2026-07-25T12:00:00+01:00",
  "second_end": "2026-07-25T13:00:00+01:00"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "date.intervals_gap",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_chars35
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →