Linux时间转换
# -*- coding: utf-8 -*-import time
def timestamp_datetime(value):
formatx = '%Y-%m-%d %H:%M:%S'
value = time.localtime(value)
dt = time.strftime(formatx, value)
return dt
def datetime_timestamp(dt):
time.strptime(dt, '%Y-%m-%d %H:%M:%S')
s = time.mktime(time.strptime(dt, '%Y-%m-%d %H:%M:%S'))
return int(s)
if __name__ == '__main__':
# print(datetime_timestamp('2022-08-02 00:00:00'))
print(timestamp_datetime(1660284741))
# 2022-07-28 00:00:00 1658937600
# 2022-08-02 00:00:00 1659369600 感谢分享 感谢分享,非常有帮助 感谢额】分享
感谢分享,非常有帮助
感谢分享 可以可以,学到了。
页:
[1]