Python ProgrammingPython Programming

Python add N number of seconds to specific date time

import datetime

a = datetime.datetime(2020, 12, 31, 23, 59, 45)
b = a + datetime.timedelta(seconds=30)

print(a)
print(b)
Output
2020-12-31 23:59:45
2021-01-01 00:00:15