import time import datetime timestamp = 1570774556514 # 轉換成localtime time_local = time.localtime(timestamp/1000) # 轉換成新的時間格式(精確到秒) dt = time.strftime("%Y-%m-%d %H:%M:%S", time_local) print(dt) # 2019-10-11 14:15:56 d = datetime.datetime.fromtimestamp(timestamp/1000) # 精確到毫秒 str1 = d.strftime("%Y-%m-%d %H:%M:%S.%f") print(str1) # 2019-10-11 14:15:56.514000