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: