编程语言
首页 > 编程语言> > python自动化测试——时间戳转日期

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

标签:00,09,python,timeStamp,time,otherStyleTime,datetime,测试,自动化
来源: https://www.cnblogs.com/nicole-zhang/p/11498371.html