Delorean

https://delorean.readthedocs.io/en/latest/

Delorean是Python里一个很方便的日期时间库,可以让人更简单省心的获取时间,不必受困于时间模块中的各种问题。

pip3 install Delorean
from delorean import Delorean

使用:

d = Delorean()
print(d)
Delorean(datetime=datetime.datetime(2018, 5, 10, 8, 52, 23, 560811), timezone='UTC')
``这里默认的是UTC时间``

转换为国内时区

d = d.shift("Asia/Shanghai")
print(d)
Delorean(datetime=datetime.datetime(2018, 5, 10, 16, 52, 23, 560718), timezone='Asia/Shanghai')

打印datetime、date

print(d.datetime, d.date)
2018-05-10 16:58:22.397155+08:00 2018-05-10

 

posted on 2019-07-17 13:53  Orvis  阅读(253)  评论(0编辑  收藏  举报

导航