Google Time Zone API (Python)

Apr 3, 2020

Install

pip install -U googlemaps

Enable API

Enable Time Zone API at Google Cloud Console.

API Key

Create API Key at Google Cloud Console -> Credentials

  • Create credentials -> API Key (Copy API Key)
  • Restrict API Key (Optional): Select Restrict Key and select Time Zone API.

Code

import googlemapsGOOGLE_API_KEY = ...location = '41.732438,44.7688135'timestamp = None # optionalgmaps = googlemaps.Client(key=GOOGLE_API_KEY)try:    result = gmaps.timezone(location=location, timestamp=timestamp)except Exception as e:    log.error(e)

Sample Result

{    "dstOffset": 0,    "rawOffset": 14400,    "status": "OK",    "timeZoneId": "Asia/Tbilisi",    "timeZoneName": "Georgia Standard Time"}

References:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.