Python iso8601 东八区时间

Posted by wxianfeng Wed, 28 May 2014 07:40:00 GMT
import datetime
import pytz

dt = datetime.datetime.now()
print(dt)  # 2013-12-04 15:38:58.910402 本地时间,不带时区
pst = pytz.timezone('Asia/Shanghai')
dt = pst.localize(dt)
dt.astimezone(pst)
print(dt)  # 2013-12-04 15:38:58.910402+08:00