我有一个json
test
[{'id':'1',
'name':'rob',
'created':'1577431544986'
},
{'id':'2',
'name':'tom',
'created':'1566431234567'
}]
我需要将UNIX时间戳转换为标准日期时间。
我做了什么:我能够弄清楚是否为单个变量:
import datetime
time = '1566431234567'
your_dt = datetime.datetime.fromtimestamp(int(time)/1000)
print(your_dt.strftime("%d-%m-%Y"))
22-08-2019
但是如何在上面的json中做同样的事情?
尝试一下
from datetime import datetime
timestamp = 1577431544986
new_date = datetime.fromtimestamp(timestamp)
希望有帮助