Computes the duration between `from` and `to`. `from` and `to` are embedded specifier strings. Accepted specifier forms: - `from=now` - `from=unix=1711300000` - `from=unix_ms=1711300000000` - `from=iso=2026-04-16T09:00:00` - `from=tz=America/New_York` - `from=ip=8.8.8.8` - `from=offset=-05:00` - the same forms are accepted for `to` Timezone hint pairings: - `from_tz` only with `from=iso=...` that has no explicit offset - `from_ip`, `from_lat`/`from_lon`, and `from_offset` only with `from=iso=...` that has no explicit offset - `to_tz` only with `to=iso=...` that has no explicit offset - `to_ip`, `to_lat`/`to_lon`, and `to_offset` only with `to=iso=...` that has no explicit offset Selector semantics: - `tz=...`, `ip=...`, and `offset=...` inside `from` or `to` mean the current request-time instant resolved through that selector - those selector forms do not represent an arbitrary local wall-clock time - returned duration magnitudes are absolute; use `direction` to see whether `to` is after, before, or the same instant as `from` Business-day rules: - `holiday_country` and `holiday_subdivision` require `business_days=true` - `holiday_subdivision` also requires `holiday_country` Examples: - Selector-current instant: `/v1/time/diff?from=unix=1711300000&to=tz=America/New_York` - Wall-clock pairing: `/v1/time/diff?from=iso=2026-04-16T09:00:00&from_tz=America/New_York&to=iso=2026-04-16T09:00:00&to_tz=Europe/London` - Wall-clock via selector: `/v1/time/diff?from=iso=2026-01-01T12:00:00&from_ip=8.8.8.8&to=iso=2026-01-01T12:00:00&to_offset=-05:00`
MethodGET
Path/v1/time/diff
Parameters17
When to use it
Use diff when you need the distance between two explicit instants rather than a relative now-to-target calculation.
It is the better fit for comparisons, scheduling offsets, and business-day interval analysis.
Request shape
Both ends of the calculation are passed as explicit time specifiers.
Timezone context fields are only needed when ISO wall-clock inputs omit explicit offsets.
Selector rules
Each side can use its own time specifier form, but each specifier still needs to be internally coherent.
Business-day mode is additive and only becomes holiday-aware when the calendar fields are also provided.
Parameters
from
queryRequiredstring
Time specifier. Supported forms are `now`, `unix=<seconds>`, `unix_ms=<milliseconds>`, `iso=<ISO-8601>`, `offset=±HH:MM`, `tz=<IANA timezone>`, and `ip=<IP address>`. For `tz=...`, `ip=...`, and `offset=...`, the specifier means the current request-time instant resolved through that selector. To express a local wall-clock time, use `from=iso=...` together with one of `from_tz`, `from_ip`, `from_lat`+`from_lon`, or `from_offset`.
to
queryRequiredstring
Time specifier. Supported forms are `now`, `unix=<seconds>`, `unix_ms=<milliseconds>`, `iso=<ISO-8601>`, `offset=±HH:MM`, `tz=<IANA timezone>`, and `ip=<IP address>`. For `tz=...`, `ip=...`, and `offset=...`, the specifier means the current request-time instant resolved through that selector. To express a local wall-clock time, use `to=iso=...` together with one of `to_tz`, `to_ip`, `to_lat`+`to_lon`, or `to_offset`.
from_tz
queryOptionalstring
Used only with `from=iso=...` when the ISO value has no explicit offset.
from_ip
queryOptionalstring
Used only with `from=iso=...` when the ISO value has no explicit offset. Resolves that local wall-clock time through the timezone mapped from this IP address.
from_lat
queryOptionalnumber:double
Used only with `from=iso=...` when the ISO value has no explicit offset. Provide together with `from_lon` to resolve that local wall-clock time through the timezone mapped from these coordinates.
from_lon
queryOptionalnumber:double
Used only with `from=iso=...` when the ISO value has no explicit offset. Provide together with `from_lat`.
from_offset
queryOptionalstring
Used only with `from=iso=...` when the ISO value has no explicit offset. Interprets that local wall-clock time at this fixed UTC offset.
to_tz
queryOptionalstring
Used only with `to=iso=...` when the ISO value has no explicit offset.
to_ip
queryOptionalstring
Used only with `to=iso=...` when the ISO value has no explicit offset. Resolves that local wall-clock time through the timezone mapped from this IP address.
to_lat
queryOptionalnumber:double
Used only with `to=iso=...` when the ISO value has no explicit offset. Provide together with `to_lon` to resolve that local wall-clock time through the timezone mapped from these coordinates.
to_lon
queryOptionalnumber:double
Used only with `to=iso=...` when the ISO value has no explicit offset. Provide together with `to_lat`.
to_offset
queryOptionalstring
Used only with `to=iso=...` when the ISO value has no explicit offset. Interprets that local wall-clock time at this fixed UTC offset.
format
queryOptionalstring
Custom duration format template using `%days`, `%hours`, `%minutes`, and `%seconds`.
business_days
queryOptionalboolean
Set to `true` to enable weekday/business-day counting.
holiday_country
queryOptionalstring
ISO 3166-1 alpha-2 holiday calendar country code. Requires `business_days=true`.
holiday_subdivision
queryOptionalstring
Holiday calendar subdivision code from the upstream `python-holidays` calendar, for example `CA` or `ENG`. Requires `holiday_country` and `business_days=true`.
sign
queryOptionalboolean
Set to `true` to ask the gateway to sign the final JSON response. Not supported on `/v1/time/clock`.
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program {
static async Task Main() {
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://timelogic-api-world-time-timezones-time-calculations.p.rapidapi.com/v1/time/diff?from=iso%3D2026-04-16T09%3A30%3A00&from_tz=America%2FLos_Angeles&to=tz%3DEurope%2FLondon&business_days=true&holiday_country=US");
request.Headers.Add("X-RapidAPI-Key", Environment.GetEnvironmentVariable("TIMELOGIC_API_KEY"));
request.Headers.Add("X-RapidAPI-Host", "timelogic-api-world-time-timezones-time-calculations.p.rapidapi.com");
using var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
}
{
"error": {
"code": "INVALID_PARAMETER",
"message": "Invalid offset. Use +HH:MM or -HH:MM."
},
"request_id": "0f8fad5b-d9cb-469f-a165-70867728950e",
"timestamp": "2026-04-15T17:30:47.883Z"
}
Ambiguous target selector error
{
"error": {
"code": "AMBIGUOUS_TARGET",
"message": "Ambiguous target selectors. Provide only one of tz, ip, lat/lon, or offset."
},
"request_id": "0f8fad5b-d9cb-469f-a165-70867728950e",
"timestamp": "2026-04-15T17:30:47.883Z"
}
Status 405
Only `GET` is supported.
Status 500
Internal server error, including signing failures.