python自動化測試——時間戳轉日期

import datetime
#十位時間戳
timeStamp = 1568131200
otherStyleTime = datetime.datetime.utcfromtimestamp(timeStamp).strftime("%Y-%m-%d %H:%M:%S")
print(otherStyleTime)  #2019-09-10 16:00:00

import time
#十三位時間戳
timeStamp = 1568131200000
otherStyleTime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(timeStamp/1000))
print(otherStyleTime) #2019-09-11 00:00:00
相關文章
相關標籤/搜索