日期到时间戳上的转换:
import datetime
import time
t = datetime.datetime(2014,12, 6, 12, 10, 10)
timestamp = time.mktime(t.timetuple())
print timestamp
时间戳到时间日期的转换:
import datetime
import time
t = time.localtime(timestamp)
timeStr = time.strftime('%Y-%m-%d %H:%M:%S', t)
print timeStr
时间日期转换星期几:
from datetime import datetime
d=datetime.date(2017,1,3)
d =datetime.today() #获取当前日期时间
d.isoweekday() #获取时间周几
参考来源:
http://blog.csdn.net/fanyunlei/article/details/36865881