How to find datetime 10 mins after current time?
Question:
I want to find out the datetime 10 mins after current time. Let’s say we have
from datetime import datetime
now = datetime.now()
new_now = datetime.strptime(now, '%a, %d %b %Y %H:%M:%S %Z')
I want to find this now
and new_now
10 minutes later. How can I do that?
Answers:
I’d add 600 to time.time()
>>> import time
>>> print time.ctime()
Wed Jun 1 13:49:09 2011
>>> future = time.time() + 600
>>> print time.ctime(future)
Wed Jun 1 13:59:15 2011
>>>
now_plus_10m = now + datetime.timedelta(minutes = 10)
See arguments you can pass in the docs for timedelta.
I want to find out the datetime 10 mins after current time. Let’s say we have
from datetime import datetime
now = datetime.now()
new_now = datetime.strptime(now, '%a, %d %b %Y %H:%M:%S %Z')
I want to find this now
and new_now
10 minutes later. How can I do that?
I’d add 600 to time.time()
>>> import time
>>> print time.ctime()
Wed Jun 1 13:49:09 2011
>>> future = time.time() + 600
>>> print time.ctime(future)
Wed Jun 1 13:59:15 2011
>>>
now_plus_10m = now + datetime.timedelta(minutes = 10)
See arguments you can pass in the docs for timedelta.