Time Zone API quick reference

The Time Zone API is an HTTPS web service that accepts latitude/longitude coordinates and a timestamp and returns the time zone ID, time zone name (optionally localized), offset from UTC, and daylight saving offset for that location, in JSON or XML.

Time Zone API: key facts

  • Product: Time Zone API
  • Category: Places
  • Platform: Web service (REST)
  • Runs on: Server (backend code)
  • Launch stage: GA
  • Lifecycle: Active
  • Overview: Time Zone API overview

Time Zone API: when to use it

Use Time Zone API when:

  • You need the time zone ID (for example, America/Los_Angeles) for a latitude/longitude pair.
  • You need the UTC offset and daylight saving offset for a location at a specific timestamp.
  • You need to calculate the local time at a location from a UTC timestamp.
  • You need localized time zone names for map locations by passing a language parameter.

Time Zone API: setup

Time Zone API: common mistakes

  • Problem: For a past timestamp, the API uses the location's current timeZoneId. It doesn't account for the location having been in a different time zone, so results for places whose zone boundaries changed can be wrong, and no error is returned. Fix: Don't rely on the API for historical time zone boundary changes; handle historical cases separately. See /maps/documentation/timezone/requests-timezone.
  • Problem: Requests for locations over water (oceans or seas) can return ZERO_RESULTS because time zone data may not be available there. Fix: Send coordinates on land and handle the ZERO_RESULTS status. See /maps/documentation/timezone/requests-timezone.
  • Problem: Computing local time from rawOffset alone gives wrong results during daylight saving time, because rawOffset excludes DST. Fix: Calculate local time as timestamp + dstOffset + rawOffset. See /maps/documentation/timezone/requests-timezone.
  • Problem: When a time zone has several IDs, the canonical CLDR ID is returned (for example, Asia/Calcutta, not Asia/Kolkata), which can break exact string matches against IANA names. Fix: Map aliases when comparing timeZoneId values with other time zone ID lists. See /maps/documentation/timezone/requests-timezone.
  • Problem: Sending the API key in the X-Goog-Api-Key header instead of the key query parameter returns REQUEST_DENIED ("You must use an API key to authenticate each request to Google Maps Platform APIs..."). Fix: Pass the API key as the key URL query parameter. See /maps/documentation/timezone/requests-timezone.

What you can do with Time Zone API

See the guides linked below for each task, or compare across products in the Capabilities Explorer.