Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find datetime 10 mins after current time?

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?

like image 211
sam Avatar asked Jun 01 '11 17:06

sam


People also ask

How can I get minutes from datetime?

To get the current time in particular, you can use the strftime() method and pass into it the string ”%H:%M:%S” representing hours, minutes, and seconds.

How do you set a specific time in Python?

time() :- This function is used to count the number of seconds elapsed since the epoch. 2. gmtime(sec) :- This function returns a structure with 9 values each representing a time attribute in sequence. It converts seconds into time attributes(days, years, months etc.)


1 Answers

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) 
like image 173
efalconer Avatar answered Oct 01 '22 19:10

efalconer