How to get a time zone from a location using latitude and longitude coordinates?

后端 未结 17 1554
走了就别回头了
走了就别回头了 2020-11-21 04:38

Given the latitude and longitude of a location, how does one know what time zone is in effect in that location?

In most cases, we are looking for an IANA/Olson time z

17条回答
  •  臣服心动
    2020-11-21 04:52

    From Guppy:

    import geocoders
    g = geocoders.GoogleV3()
    place, (lat, lng) = g.geocode('Fairbanks')
    print place, (lat, lng)
    Fairbanks, AK, USA (64.8377778, -147.7163889)
    timezone = g.timezone((lat, lng))
    print timezone.dst
    

    Bound method America/Anchorage.dst of DstTzInfo

    America/Anchorage' LMT-1 day, 14:00:00 STD

提交回复
热议问题