Python时间转换
from datetime import datetime # 年月日时分秒微秒转浮点数时间 date = datetime(2022, 10, 19, 15, 29, 25, 1000) timestamp = date.timestamp() print(timestamp) # 浮点数时间戳转年月日时分秒 new_date = datetime.fromtimestamp(1666190857.9792) print(new_date)
from datetime import datetime # 年月日时分秒微秒转浮点数时间 date = datetime(2022, 10, 19, 15, 29, 25, 1000) timestamp = date.timestamp() print(timestamp) # 浮点数时间戳转年月日时分秒 new_date = datetime.fromtimestamp(1666190857.9792) print(new_date)