python:將時間戳格式化為yyyyMMdd hh:mm:ss


 

import time

#將10位時間戳或者13位轉換為時間字符串,默認為2017-10-01 13:37:04格式
def timestamp_to_date(time_stamp, format_string="%Y-%m-%d %H:%M:%S"):
    time_array = time.localtime(time_stamp/1000)
    other_style_time = time.strftime(format_string, time_array)
    print other_style_time
    return other_style_time
timestamp_to_date(1593693029909)

輸出

2020-07-02 20:30:29

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM