API
公开时间 API(v1)
提供当前瞬间、格式转换与时区转换的 JSON 接口。CORS *,v1 无需 API 密钥。限流:每个 IP 每 60 秒 120 次请求;超出后返回 HTTP 429,并带 Retry-After 头。请勿用于安全关键计时。
GET /api/v1/now
查询参数:format(iso | unix | unix_ms | rfc2822 | http | custom)、tz(IANA)、自定义时可选 pattern(YYYY MM DD HH mm ss Z X x)。
curl "https://time.foo/api/v1/now?format=iso&tz=Asia/Singapore"
GET /api/v1/convert
查询参数:from(ISO 或 unix 秒/毫秒)、from_tz、to_tz、format,可选 pattern。
curl "https://time.foo/api/v1/convert?from=1700000000&to_tz=America/New_York&format=iso"
GET /api/v1/timezone
查询参数:可选 time、from_tz、to_tz — 返回两个时区的偏移与 ISO 标签。
curl "https://time.foo/api/v1/timezone?from_tz=UTC&to_tz=Asia/Tokyo"
发现
GET /api/v1/ 返回 JSON 索引。错误形如 {"error":"bad_request","message":"..."}。
未知的查询参数会返回 400,并列出可用参数(例如 /timezone 用 from_tz 和 to_tz,不用 tz)。