时间单位转化

# coding:utf-8
import datetime

utc_time = datetime.datetime.utcnow()
# 北京时间(东八区)
bj_time = (datetime.datetime.utcnow() + datetime.timedelta(hours=8))
# 美国密西根时间(西五区)
us_time = (datetime.datetime.utcnow() - datetime.timedelta(hours=5))

print bj_time.strftime("%Y-%m-%d %H:%M:%S")
print us_time.strftime("%Y-%m-%d %H:%M:%S")

  

posted @ 2017-08-13 11:14  kingrain  阅读(162)  评论(0编辑  收藏  举报