<p>I would like to find out if a particular python datetime object is older than X hours or minutes. I am trying to do something similar to:  </p>

<pre><code>if (datetime.now() - self.timestamp) &gt; 100
# Where 100 is either seconds or minutes
</code></pre>

<p>This generates a type error. </p>

<p>What is the proper way to do date time comparison in python? I already looked at <a href="http://wiki.python.org/moin/WorkingWithTime" rel="noreferrer">WorkingWithTime</a> which is close but not exactly what I want. I assume I just want the datetime object represented in seconds so that I can do a normal int comparison. </p>

<p>Please post lists of datetime best practices.</p>

You can subtract two
datetime
objects to find the difference between them.
You can use
```
datetime.fromtimestamp
```
to parse a POSIX time stamp.