How to find datetime 10 mins after current time?

前端 未结 3 833
梦毁少年i
梦毁少年i 2020-12-05 06:16

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.str         


        
相关标签:
3条回答
  • 2020-12-05 06:32

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

    now = datetime.datetime.now()
    now_plus_10 = now + datetime.timedelta(minutes = 10)
    
    0 讨论(0)
  • 2020-12-05 06:55

    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
    >>> 
    
    0 讨论(0)
  • 2020-12-05 06:56
    now_plus_10m = now + datetime.timedelta(minutes = 10)
    

    See arguments you can pass in the docs for timedelta.

    0 讨论(0)
提交回复
热议问题