Hide

The Google Maps Time Zone API

The Google Maps Time Zone API provides a simple interface to request the time zone for a location on the earth, as well as that location's time offset from UTC.

This service is also available with a Java client library.

  1. Introduction
  2. Audience
  3. API Key
  4. Usage Limits
  5. Time Zone Requests
    1. Output Formats
    2. Parameter Usage
  6. Time Zone Responses
  7. Example Requests

Introduction

The Google Maps Time Zone API provides time offset data for locations on the surface of the earth. Requesting the time zone information for a specific Latitude/Longitude pair will return the name of that time zone, the time offset from UTC, and the Daylight Savings offset.

You access the Google Maps Time Zone API through an HTTPS interface.

Get a Key Usage Limits

Audience

This document is intended for website and mobile developers who want to include time data on maps provided by one of the Google Maps APIs. It provides an introduction to using the API and reference material on the available parameters.

Time Zone Requests

The Google Maps Time Zone API returns time zone data for a point on the earth, specified by a Latitude/Longitude pair. Note that time zone data may not be available for locations over water, such as oceans or seas.

A Google Maps Time Zone API URL must be of the following form:

https://maps.googleapis.com/maps/api/timezone/outputFormat?parameters

Important: You must submit requests via https, not http.

Output Formats

Outputs formats are specified using the trailing service flag in the request URL. The Google Maps Time Zone API supports the following output formats:

  • /json returns results in JavaScript Object Notation (JSON).
  • /xml returns results in XML, wrapped within a <TimeZoneResponse> node.

Parameter Usage

As is standard in all URLs, parameters are separated using the ampersand (&) character. The list of parameters and their possible values are denoted below.

Required Parameters

  • location: a comma-separated lat,lng tuple (eg. location=-33.86,151.20), representing the location to look up.
  • timestamp specifies the desired time as seconds since midnight, January 1, 1970 UTC. The Google Maps Time Zone API uses the timestamp to determine whether or not Daylight Savings should be applied. Times before 1970 can be expressed as negative values.
  • key — Your application's API key. This key identifies your application for purposes of quota management. Learn how to get a key.

Google Maps API for Work users must include valid client and signature parameters with their requests. Please refer to Google Maps API for Work Web Services for more information.

Optional Parameters

  • language — The language in which to return results. See the list of supported domain languages. Note that we often update supported languages so this list may not be exhaustive. Defaults to en.

Time Zone Responses

For each valid request, the time zone service will return a response in the format indicated within the request URL. Each response will contain the following elements:

  • dstOffset: the offset for daylight-savings time in seconds. This will be zero if the time zone is not in Daylight Savings Time during the specified timestamp.
  • rawOffset: the offset from UTC (in seconds) for the given location. This does not take into effect daylight savings.
  • timeZoneId: a string containing the "tz" ID of the time zone, such as "America/Los_Angeles" or "Australia/Sydney". These IDs are defined in the IANA Time Zone Database, which is also available in searchable format in Wikipedia's List of tz database time zones.
  • timeZoneName: a string containing the long form name of the time zone. This field will be localized if the language parameter is set. eg. "Pacific Daylight Time" or "Australian Eastern Daylight Time"
  • status: a string indicating the status of the response.
    • OK indicates that the request was successful.
    • INVALID_REQUEST indicates that the request was malformed.
    • OVER_QUERY_LIMIT indicates the requestor has exceeded quota.
    • REQUEST_DENIED indicates that the the API did not complete the request. Confirm that the request was sent over HTTPS instead of HTTP.
    • UNKNOWN_ERROR indicates an unknown error.
    • ZERO_RESULTS indicates that no time zone data could be found for the specified position or time. Confirm that the request is for a location on land, and not over water.
  • error_message: more detailed information about the reasons behind the given status code, if other than OK.

    Note: This field is not guaranteed to be always present, and its content is subject to change.

Calculating the Local Time

The local time of a given location is the sum of the timestamp parameter, and the dstOffset and rawOffset fields from the result.

Example Requests

This section includes some sample queries that demonstrate features of the API.

The below query performs a time zone request for Nevada, USA. The timestamp is set to March 8th, 2012.

JSON

Request:

https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331161200&key=API_KEY

Response:

{
   "dstOffset" : 0,
   "rawOffset" : -28800,
   "status" : "OK",
   "timeZoneId" : "America/Los_Angeles",
   "timeZoneName" : "Pacific Standard Time"
}
    
XML

Request:

https://maps.googleapis.com/maps/api/timezone/xml?location=39.6034810,-119.6822510&timestamp=1331161200&key=API_KEY

Response:

<TimeZoneResponse>
  <status>OK</status>
  <raw_offset>-28800.0000000</raw_offset>
  <dst_offset>0.0000000</dst_offset>
  <time_zone_id>America/Los_Angeles</time_zone_id>
  <time_zone_name>Pacific Standard Time</time_zone_name>
</TimeZoneResponse>

The below query performs a time zone request for Nevada, USA. The location is the same as the above request, but the timestamp is set to March 15th, 2012. The response now includes a Daylight Savings Time offset.

JSON

Request:

https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331766000&key=API_KEY

Response:

{
   "dstOffset" : 3600,
   "rawOffset" : -28800,
   "status" : "OK",
   "timeZoneId" : "America/Los_Angeles",
   "timeZoneName" : "Pacific Daylight Time"
}
    
XML

Request:

https://maps.googleapis.com/maps/api/timezone/xml?location=39.6034810,-119.6822510&timestamp=1331766000&key=API_KEY

Response:

<TimeZoneResponse>
  <status>OK</status>
  <raw_offset>-28800.0000000</raw_offset>
  <dst_offset>3600.0000000</dst_offset>
  <time_zone_id>America/Los_Angeles</time_zone_id>
  <time_zone_name>Pacific Daylight Time</time_zone_name>
</TimeZoneResponse>

This example is similar to the above two, but sets a language parameter. The response will now be localized to Spanish.

JSON

Request:

https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331766000&language=es&key=API_KEY

Response:

{
   "dstOffset" : 3600,
   "rawOffset" : -28800,
   "status" : "OK",
   "timeZoneId" : "America/Los_Angeles",
   "timeZoneName" : "Hora de verano del Pacífico"
}
    
XML

Request:

https://maps.googleapis.com/maps/api/timezone/xml?location=39.6034810,-119.6822510&timestamp=1331766000&language=es&key=API_KEY

Response:

<TimeZoneResponse>
  <status>OK</status>
  <raw_offset>-28800.0000000</raw_offset>
  <dst_offset>3600.0000000</dst_offset>
  <time_zone_id>America/Los_Angeles</time_zone_id>
  <time_zone_name>Hora de verano del Pacífico</time_zone_name>
</TimeZoneResponse>

The sensor Parameter

The Google Maps API previously required that you include the sensor parameter to indicate whether your application used a sensor to determine the user's location. This parameter is no longer required.

Send feedback about...

Google Maps Time Zone API
Need help? Visit our support page.