Calculating difference in days using PHP Interval Object?
<p>I've already seen some answers in StackOverflow about how to calculate difference in time between two dates. But no answer are using the DateTime obejct or the Interval Object in PHP. I got the following code snippet from PHP Manual website: <a href="http://www.php.net/manual/en/dateinterval.format.php" rel="nofollow">http://www.php.net/manual/en/dateinterval.format.php</a>.</p>

<pre><code>&lt;?php

$january = new DateTime('2010-01-01');
$february = new DateTime('2010-02-01');
$interval = $february-&gt;diff($january);

// %a will output the total number of days.
echo $interval-&gt;format('%a total days')."\n";

// While %d will only output the number of days not already covered by the
// month.
echo $interval-&gt;format('%m month, %d days');

?&gt;
</code></pre>

<p>But the problem is that total days equals 6015 days when it should only be 31 days. I tried to access the instance variable days in the Interval object. It too shows 6015 days. But the instances for month and days intervals are correct. Can someone tell me why?</p>

<p>And I want to use these objects to calculate the difference in times!</p>

<p>Many thanks</p>

<p>UPDATE:</p>

<p>I think it was just a problem with my PHP setup</p>
