python 转换Unix时间戳可以使用python中的time模块和datetime模块
time
# -*- coding: utf-8 -*-
import time
# new_date = time.ctime(Unix时间戳)
new_date = time.ctime(1567764428)
print(new_date) # Fri Sep 6 18:07:08 2019
datetime
# -*- coding: utf-8 -*-
import datetime
# new_date = datetime.datetime.fromtimestamp(Unix时间)
new_date = datetime.datetime.fromtimestamp(1567764428)
print(new_date) # 2019-09-06 18:07:08
# 只获取小时
print(new_date.hour)
# 只获取分钟
print(new_date.minute)
# 只获取秒
print(new_date.second)
# 只获取年
print(new_date.year)
# 只获取月
print(new_date.month)
# 只获取天
print(new_date.day)
相关内容:
python time:
Python datetime:
datetime — Basic date and time types — Python 3.10.4 documentation