Possible Duplicates:
Python - easy way to add N seconds to a datetime.time?
How to create a DateTime equal to 15 minutes ago?
what's the best way to do this?
Use the timedelta() class from the datetime module to add minutes to datetime, e.g. result = dt + timedelta(minutes=10) . The timedelta class can be passed a minutes argument and adds the specified number of minutes to the datetime.
d1 = datetime.datetime.now() + datetime.timedelta(minutes=15)
d2 = datetime.datetime.now() + datetime.timedelta(hours=1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With