By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,171 Members | 776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,171 IT Pros & Developers. It's quick & easy.

timedelta comparision with gmtime()

P: n/a
I want to know if a certain duration is over.
I try it like this with timedelta objects:

d = datetime.timedelta(minutes = 2)
t = time.gmtime()
print (t + d < time.gmtime())


TypeError: unsupported operand type(s) for +: 'datetime.timedelta' and

How to do that right?


Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
martin@ubuntu:~ $ python
Use now() from datetime class of datetime module instead of time

Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
py> import datetime
py> t =
py> print t
2005-06-22 20:22:36.212142
py> d = datetime.timedelta(minutes = 2)
py> print t + d
2005-06-22 20:24:36.212142

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.