python时区处理

发布时间:2019-07-25 09:13:04编辑:auto阅读(1486)

    import dateutil
    from dateutil import tz
    utc = tz.tzutc()
    
    t = dateutil.parser.parse("2017-02-24T19:36:20-05:00")
    print t
    #输出
    #datetime.datetime(2017, 2, 24, 19, 36, 20, tzinfo=tzoffset(None, -18000))
    
    t.astimezone(utc)
    #输出
    #datetime.datetime(2017, 2, 25, 0, 36, 20, tzinfo=tzutc())
    

关键字