Get difference in days between today's date and previous date
<p>I'm using the "datetime" module and I'm trying to work out the difference between two dates in <strong>days</strong>. Here's the code that I'm using, with some other code coming before it that gets the object <code>sub.created_utc</code> (a POSIX timestamp, or unix timestap):</p>

<pre><code>import datetime

date = datetime.datetime.utcfromtimestamp(sub.created_utc);
print(sub.created_utc);
print(date);
print(datetime.datetime.now() - date);
</code></pre>

<p>and here is the output:</p>

<pre><code>1440736746.0
2015-08-28 04:39:06
287 days, 16:47:41.560711
</code></pre>

<p>My question is, how do I get the <code>287 days</code> part of that (or just <code>287</code>, I don't mind either way). I know I could use regex to just extract that part of it, but is there a better more reliable way of doing it?</p>

<p>Thanks for any help! If you want me to give the full code I can provide it, just wouldn't think it would be necessary.</p>