AnvilJSON utilities

Anvil › Docs › /v1/time

Current time API for any time zone, with next DST change

Ask what time it is in Europe/London, Asia/Kolkata or any other IANA zone and get the local time, its UTC offset, the abbreviation (GMT, BST, IST…), whether daylight saving is in force, the ISO week number, and when the clocks next change.

In one line: GET /v1/time?tz=Europe/London returns JSON. No key, CORS on, 60 requests a minute.
GET

/v1/time

Current time (or any moment) in a time zone, with next DST change. Change the values and press Send request to call the live API.

Parameters

NameTypeWhat it doesDefault
tzstringIANA zone like Europe/LondonUTC
atstring'now', a Unix timestamp, or ISO 8601now

Example

Request:

GET https://api.oddlathe.com/v1/time?tz=Europe/London

Response (generated by the real code when these docs were last built; random or time-based values will differ for you):

{
 "timezone": "Europe/London",
 "next_change": {
  "at_utc": "2027-03-28T01:00Z",
  "local_before": "2027-03-28T00:59+00:00",
  "local_after": "2027-03-28T02:00+01:00",
  "new_offset": "+01:00"
 },
 "moment": {
  "iso": "2026-11-12T01:21:01+00:00",
  "date": "2026-11-12",
  "time": "01:21:01",
  "weekday": "Thursday",
  "utc_offset": "+00:00",
  "abbreviation": "GMT",
  "dst": false,
  "unix": 1794446461,
  "iso_week": 46,
  "day_of_year": 316
 }
}

Code examples

curl
curl 'https://api.oddlathe.com/v1/time?tz=Europe/London'
JavaScript (browser or Node 18+)
const params = new URLSearchParams({
  tz: "Europe/London"
});
const res = await fetch(`https://api.oddlathe.com/v1/time?${params}`);
if (!res.ok) throw new Error((await res.json()).error.message);
const data = await res.json();
console.log(data);
Python (standard library only)
import json, urllib.parse, urllib.request

params = urllib.parse.urlencode({"tz": "Europe/London"})
url = "https://api.oddlathe.com/v1/time?" + params
# Send a User-Agent: the edge network refuses Python's default one.
req = urllib.request.Request(url, headers={"User-Agent": "my-script/1.0"})
with urllib.request.urlopen(req, timeout=10) as r:
    data = json.load(r)
print(data)

When it's useful

  • Showing "it's 3:12 pm for your colleague in Sydney" on a dashboard
  • Checking a device clock or a scheduler against a reliable source
  • Finding the next clock change before planning a release or a night shift

Good to know

  • Time zone names follow the IANA database: Area/City, like America/New_York. Abbreviations such as EST are ambiguous and not accepted. The full list is at /v1/timezones.
  • at accepts now, a Unix timestamp in seconds, or ISO 8601. Timestamps above 10¹¹ are treated as milliseconds. An ISO time without an offset is read as local time in tz.
  • The next change is found by searching the next two years and narrowing to the exact second.

Includes UTC offset, abbreviation, whether daylight saving is in force, ISO week and the next offset change (if the zone has one in the next two years).

Errors

Errors are JSON like {"error": {"code": "…", "message": "…"}}. The ones this endpoint can return:

  • bad_param (400): a value is the wrong type or out of range (the message says which)
  • bad_timezone (400): the zone isn't a known IANA name
  • rate_limited (429): over 60 requests a minute; wait for Retry-After seconds

Questions

Why do I need a city name instead of an offset like +01:00?

Offsets change during the year and over the decades. A zone name carries the whole rule history, so the API can tell you about DST and future changes.

Is this accurate enough to set a clock?

It's the server's clock, kept in sync with NTP, plus network delay to you. Fine to the second for most uses; use NTP for anything tighter.

Related endpoints

Prefer a page to an API?

Published , updated · OpenAPI 3.1 spec · Limits and privacy