Get the timezone from latitude and longitude (coordinates to IANA time zone)
Turn latitude and longitude into an IANA time zone, UTC offset and DST flag with one API call. curl, JavaScript and Python examples, plus edge cases.
Updated
Short answer: pass the coordinates to a time zone API. GET /v1/timezone?lat=35.6762&lon=139.6503 returns Asia/Tokyo, the current offset (540 minutes) and whether daylight saving time is in effect.
curl "https://api.timelogicapi.com/v1/timezone?lat=35.6762&lon=139.6503&api_key=$TIMELOGIC_API_KEY"
{
"unix": 1793377373,
"unix_ms": 1793377373293,
"utc": "2026-10-30T16:22:53Z",
"iso_local": "2026-10-31T01:22:53+09:00",
"rfc2822": "Sat, 31 Oct 2026 01:22:53 +0900",
"human": "October 31, 2026, 1:22 AM Asia/Tokyo",
"day_number": 7,
"day_short": "Sat",
"day_full": "Saturday",
"timezone": "Asia/Tokyo",
"offset": 540,
"dst": false
}
A real response from October 30, 2026. Sydney (lat=-33.8688&lon=151.2093) returned Australia/Sydney with offset: 660 and dst: true in the same minute.
Why not compute the zone from longitude?
Time zones are political borders, not 15-degree stripes. Two points at the same longitude can be hours apart, a country can shift its offset by law, and daylight saving rules differ by region. A lookup against current boundary and tz data gives the canonical IANA name, which is also what you should store.
JavaScript: coordinates to time zone
async function timezoneAt(lat, lon) {
const url = new URL("https://api.timelogicapi.com/v1/timezone");
url.search = new URLSearchParams({ lat, lon });
const res = await fetch(url, { headers: { "X-API-Key": process.env.TIMELOGIC_API_KEY } });
if (!res.ok) throw new Error(`TimeLogic API ${res.status}`);
const { timezone, offset, dst } = await res.json();
return { timezone, offset, dst };
}
console.log(await timezoneAt(48.8566, 2.3522)); // { timezone: "Europe/Paris", ... }
Python: latitude and longitude to time zone
import os, requests
def timezone_at(lat: float, lon: float) -> str:
r = requests.get(
"https://api.timelogicapi.com/v1/timezone",
params={"lat": lat, "lon": lon},
headers={"X-API-Key": os.environ["TIMELOGIC_API_KEY"]},
timeout=5,
)
r.raise_for_status()
return r.json()["timezone"]
print(timezone_at(-33.8688, 151.2093)) # Australia/Sydney
The local time at a GPS position
Skip the second step: GET /v1/time/current?lat=40.7128&lon=-74.006 returns the current local time at that point (America/New_York) with Unix time, UTC, ISO 8601 and RFC 2822. Add format= with a strftime pattern for your own layout; see the current time reference.
Errors to handle
- Only one of
lat/lon:400 INVALID_PARAMETER, "Both 'lat' and 'lon' must be provided together." - Out-of-range values (for example
lat=95):400 INVALID_PARAMETER, "Invalid coordinates." - Mixing coordinates with
tzoripin one request:400 AMBIGUOUS_TARGET.
Related guides
- Time zone API guide (pillar): every selector, including names, IPs, coordinates and offsets
- Get the timezone from an IP address
- Time API comparison: how TimeLogic compares with other coordinate lookups
- Resolve timezone reference
Frequently asked questions
How do I get the time zone from latitude and longitude?
Send both values to GET https://api.timelogicapi.com/v1/timezone?lat=35.6762&lon=139.6503 with your API key. The response names the IANA zone (Asia/Tokyo), the current offset in minutes, the DST flag and the local time.
Can I calculate the time zone from longitude alone?
Only roughly. Longitude divided by 15 gives a nautical offset, but real time zones follow borders and change with laws and daylight saving rules. Spain and western China are well-known examples where the zone does not match the longitude. Look the point up instead.
Do I need both lat and lon?
Yes. A request with only lat returns 400 INVALID_PARAMETER ("Both 'lat' and 'lon' must be provided together."), and values outside the valid range return 400 "Invalid coordinates."
Can I get the current time at a GPS position directly?
Yes. GET /v1/time/current?lat=40.7128&lon=-74.006 returns the local time there (America/New_York), with Unix time, UTC, ISO 8601 and RFC 2822.
What is the Google Time Zone API alternative for coordinates?
TimeLogic's /v1/timezone takes the same latitude/longitude input and returns the IANA time zone, current offset and DST flag. The same endpoint also accepts an IP address or an IANA name, and the Free plan covers 10,000 requests a month.