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
languageparameter.
Time Zone API: setup
- Service to enable:
timezone-backend.googleapis.com - Authentication: API key
- Get started: Set up Time Zone API
- Reference: Time Zone API reference
- Pricing: Time Zone API usage and billing
- Policies: Time Zone API policies
Time Zone API: common mistakes
- Problem: For a past
timestamp, the API uses the location's currenttimeZoneId. 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_RESULTSbecause time zone data may not be available there. Fix: Send coordinates on land and handle theZERO_RESULTSstatus. See /maps/documentation/timezone/requests-timezone. - Problem: Computing local time from
rawOffsetalone gives wrong results during daylight saving time, becauserawOffsetexcludes DST. Fix: Calculate local time astimestamp + 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, notAsia/Kolkata), which can break exact string matches against IANA names. Fix: Map aliases when comparingtimeZoneIdvalues with other time zone ID lists. See /maps/documentation/timezone/requests-timezone. - Problem: Sending the API key in the
X-Goog-Api-Keyheader instead of thekeyquery parameter returnsREQUEST_DENIED("You must use an API key to authenticate each request to Google Maps Platform APIs..."). Fix: Pass the API key as thekeyURL 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.
- Return the time zone for a timestamp and set of latitude/longitude coordinates.
- Return daylight savings offset information for a time zone.
- Specify the language for time zone requests.
- Return the Unicode Common Locale Data Repository (CLDR) ID for a time zone.
- Return the offset from UTC (in seconds) for a time zone.