将时间戳转换为年月日时分秒格式:
import datetime
timeStamp = 1511169651
dateArray = datetime.datetime.utcfromtimestamp(timeStamp)
print dateArray
otherStyleTime = dateArray.strftime("%Y-%m-%d %H:%M:%S")
print otherStyleTime
将年月日时分秒格式转换为时间戳:
import time
a = "2017-11-14 13:30:00"
timeArray = time.strptime(a, "%Y-%m-%d %H:%M:%S")
timeStamp = int(time.mktime(timeArray))
print timeStamp
网友评论