Get Timezone from City in Python/Django

后端 未结 6 1595
独厮守ぢ
独厮守ぢ 2020-11-27 06:00

Using pytz, I am able to get a list of timezones like so:

>>> from pytz import country_timezones
>>> print(\' \'.join(country_         


        
6条回答
  •  面向向阳花
    2020-11-27 06:38

    There is not trivial way of doing this, which is unfortunate. Geonames records a list of every city, along with its time zone name. This would be a god pick, but you will have to parse and build your own database around this, so you can easily find at any moment the time zone from a country/city pair.

提交回复
热议问题