unexpected results converting timezones in python

前端 未结 5 1988
谎友^
谎友^ 2020-11-27 17:27

I\'m trying to understand why I\'m getting these results when converting timezones to UTC:

In [74]: d1 = datetime(2007, 12, 5, 6, 30,tzinfo=pytz.timezone(\'U         


        
5条回答
  •  野性不改
    2020-11-27 18:02

    From the partial documentation: http://pytz.sourceforge.net/#localized-times-and-date-arithmetic

    Unfortunately using the tzinfo argument of the standard datetime constructors ‘’does not work’’ with pytz for many timezones. [...] It is safe for timezones without daylight saving transitions though, such as UTC. [...] The preferred way of dealing with times is to always work in UTC, converting to localtime only when generating output to be read by humans.

提交回复
热议问题