Subtract time from time with php
<p>Hi i have a database which has the pages a visitor has viewed and the time which they landed on that page.  what i am trying to do is take the time the visitor views page A then the time the visitor views page b and then subtract A from B to get how long the visitor stayed on that page for.</p>

<p>at the moment, in my example the difference is two seconds but the result is returned as zero, is this because 2 seconds is  a low number that the result is rounded up?</p>

<p>Here is my code.</p>

<pre><code>$a = new DateTime('09:14:52');
$b = new DateTime('09:14:54');
$interval = $a-&gt;diff($b);

echo $interval-&gt;format("%H");
</code></pre>

<p>Thanks</p>
