I want to be able to implement a condition in my program where it would only run for N number of hours, maybe the user could specify N, but let's not jump ahead.
I figured I could use datetime.now()
and store the value below in a variable, time
>>> time
>>> time = datetime.datetime(2013, 12, 9, 21, 50, 32, 405329)
Any ideas on how I can access the fourth field between the (--), seeing as it's a string?
My condition would be something like while time != timeEnd
where timeEnd would be the value of below:
>>> timeEnd = datetime.datetime(2013, 12, 9, 21+N, 50, 32, 405329)
Thanks
You can add a
timedelta
to adatetime
to get a newdatetime
.Then...