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

This entry was posted on Wed, 28 May 2014 07:40:00 GMT and Posted in . You can follow any any response to this entry through the Atom feed. You can leave a comment or a trackback from your own site.

Tags ,


Trackbacks

Use the following link to trackback from your own site:
http://blog.wxianfeng.com/trackbacks?article_id=325

Comments

Leave a comment