时区查询

一个点的时区,以及该处在指定时刻生效的偏移量。

GEThttps://api.mygeocode.com/v1/timezone

参数

参数类型说明
lat必填*数字-90 到 90。
lon必填数字-180 到 180。
locations可选字符串*latlon 的替代方式:最多 100 个点,格式为 lat,lon|lat,lon|...。每个点计为一次请求;响应带有按输入顺序排列的 results 数组。
tz可选字符串*坐标的替代方式:IANA 时区 ID,例如 Europe/Zurich(也接受 Windows ID)。返回该时区的相同字段,不进行边界查找。
timestamp可选整数以秒为单位的 Unix 时间。默认:当前时间。接受 1900 到 2100 之间的任何时刻;未来的偏移量使用当前公布的规则。
language可选字符串name 所用的语言,例如 dept-BR。默认为英语。
key可选字符串API 密钥(如果未通过请求头发送)。

示例

$ curl -H "X-API-Key: YOUR_KEY" "https://api.mygeocode.com/v1/timezone?lat=-33.8688&lon=151.2093&timestamp=1767225600"
const url = new URL("https://api.mygeocode.com/v1/timezone");
url.searchParams.set("lat", -33.8688);
url.searchParams.set("lon", 151.2093);
url.searchParams.set("timestamp", 1767225600); // 2026-01-01T00:00:00Z

const tz = await (await fetch(url, { headers: { "X-API-Key": "YOUR_KEY" } })).json();
console.log(tz.timezone, tz.utc_offset, tz.dst);
import requests

tz = requests.get("https://api.mygeocode.com/v1/timezone",
                  params={"lat": -33.8688, "lon": 151.2093, "timestamp": 1767225600}, headers={"X-API-Key": "YOUR_KEY"}, timeout=5).json()
print(tz["timezone"], tz["utc_offset"], tz["dst"])
响应
{
  "status": "ok",
  "lat": -33.8688,
  "lon": 151.2093,
  "timezone": "Australia/Sydney",
  "abbreviation": "AEDT",
  "utc_offset": "+11:00",
  "utc_offset_seconds": 39600,
  "dst": true,
  "timestamp": 1767225600,
  "local_time": "2026-01-01T11:00:00+11:00",
  "country_code": "AU",
  "next_transition": { "timestamp": 1775316000, "utc_offset": "+10:00", "dst": false }
}

响应字段

字段类型说明
timezone字符串IANA 名称。在国际水域为 Etc/GMT+nEtc/GMT-n(请注意,与 IANA 一样,正负号约定是相反的)。
abbreviation字符串timestamp 时的缩写。仅用于显示;不唯一。
name字符串timestamp 时生效的完整名称,例如 Australian Eastern Daylight Time。
utc_offset字符串timestamp 时的 ±HH:MM
utc_offset_seconds整数以数字表示的同一值。
raw_offset_seconds, dst_offset_seconds整数标准偏移量,以及在其基础上叠加的夏令时部分(未实行夏令时时为 0)。两者之和为 utc_offset_seconds
dst布尔值timestamp 时是否实行夏令时。
timestamp整数所描述的时刻。
local_time字符串带偏移量的 RFC 3339 当地时间。
country_code字符串或 nullISO 3166-1 alpha-2,海上为 null。
is_ocean布尔值对于国际水域使用的 Etc/GMT 时区为 true。
windows_timezone字符串或 null来自 CLDR 的对应 Windows 时区 ID,例如 W. Europe Standard Time。
next_transition对象或 nulltimestamp 之后的下一次偏移量变化(如果该时区有的话)。

注意事项

以其他服务商格式进行的同一查询

如果您已有针对这些服务商之一编写的代码,请保留它:兼容替换主机接受相同的路径和参数,并以该服务商的响应结构作答,背后由此端点提供支持。请参阅兼容替换主机的工作原理

服务商主机路径
Google Maps 平台gapi.mygeocode.com/maps/api/timezone/json?location=lat,lng&timestamp=...&language=..
Bing Maps REST 服务bing.mygeocode.com/REST/v1/TimeZone/{lat},{lon}?datetime=...
/REST/v1/TimeZone/?query=lat,lon
/REST/v1/TimeZone/List?timezoneStandard=iana|windows
/REST/v1/TimeZone/Convert?datetime=...&fromtz=...&desttz=...
LocationIQlocationiq.mygeocode.com/v1/timezone?lat=...&lon=...

错误

latlon 缺失或超出范围、tz 不是已知时区、点数超过 100 个,或 timestamp 超出 1900 到 2100 的范围时,返回 400 invalid_request。当边界数据未加载时返回 503 unavailable;不计数。