如何查找当前时间后10分钟的日期时间?

我想知道当前时间后10分钟的日期时间

from datetime import datetime
now = datetime.now()
new_now = datetime.strptime(now, '%a, %d %b %Y %H:%M:%S %Z')

我想在10分钟后找到这个 nownew_now。我该怎么做?

117954 次浏览

This is a duplicate of this question. You basically just need to add a timedelta of 10 minutes to get the time you want.

from datetime import datetime, timedelta
now = datetime.now()
now_plus_10 = now + timedelta(minutes = 10)

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.