时间戳转成日期
import time,datetime
now = int(time.time())
timeArray = time.localtime(now)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
print(otherStyleTime)
now = datetime.datetime.now()
otherStyleTime = now.strftime("%Y-%m-%d %H:%M:%S")
print(otherStyleTime)
timeStamp = 1589857200
timeArray = time.localtime(timeStamp)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
print(otherStyleTime)
timeStamp = 1589857200
dateArray = datetime.datetime.utcfromtimestamp(timeStamp)
otherStyleTime = dateArray.strftime("%Y-%m-%d %H:%M:%S")
print(otherStyleTime)
日期转成时间戳
import time,datetime
print('日期转成时间戳')
tss1 = '2020-05-19 11:00:00'
timeArray = time.strptime(tss1, "%Y-%m-%d %H:%M:%S")
print(timeArray)
print(timeArray.tm_year)
timeStamp = int(time.mktime(timeArray))
print(timeStamp)