目录
1.代码及运行结果
import datetime
def to_date(date_fourteen):
"""
指定時間を60秒追加
"""
year = int(date_fourteen[0:4])
month = int(date_fourteen[4:6])
day = int(date_fourteen[6:8])
hour = int(date_fourteen[8:10])
minute = int(date_fourteen[10:12])
second = int(date_fourteen[12:14])
dt_obj = datetime.datetime(
year,
month,
day,
hour,
minute,
second
)
date = dt_obj + datetime.timedelta(days=0, hours=0, seconds=60)
str_fourteen = date.strftime('%Y%m%d%H%M%S')
return str_fourteen
if __name__ == '__main__':
# 2022/11/20 22:40:00
data_str = '20221120224000'
# return 20221120224100
data_new = to_date(data_str)
print(data_new)