how to add time with time delta in python

Solutions on MaxInterview for how to add time with time delta in python by the best coders in the world

showing results for - "how to add time with time delta in python"
Lyana
08 Jul 2017
1from datetime import timedelta, datetime
2now = datetime.now()
3print("Today is:-",now)
4print("600 hours later than today will be", str(now + timedelta(hours=600)))
Gabriele
28 Feb 2020
1import datetime
2
3ts = ts + datetime.timedelta(seconds=1)
4ts = ts + datetime.timedelta(minutes=1)
5ts = ts + datetime.timedelta(hours=1)
6ts = ts + datetime.timedelta(days=1)