python 13位时间戳转为10位时间戳
2020-10-27 本文已影响0人
程序里的小仙女
import datetime,time
var = 1458365220000
print(var)
str_time = datetime.datetime.fromtimestamp(var / 1000)
# temp = datetime.datetime.fromtimestamp(var / 1000).strftime("%Y-%m-%d %H:%M:%S")
print (str_time)
str_time = '2016-03-19 13:27:00'
t10 = time.mktime(time.strptime(str_time, '%Y-%m-%d %H:%M:%S'))
t = int(t10)
print(t)