how to find the hour difference between two days in php
<p>I have a two dates </p>

<pre><code>$date1="03/17/2012 9:00 PM";
$date2=03/17/2012 9:40 PM";
</code></pre>

<p>I have to find out the hour difference between these two dates. I know it's 40minutes as manual calculation. But how I calculate this in php.
I have read many docs and tried to calculate. But I got wrong result. See my code</p>

<pre><code>$dateDiff=(strtotime($date2)-strtotime($date1))/3600
</code></pre>

<p>But I got answer 0.7. Its wrong answer</p>

<p>one more </p>

<p>how i show both the hour and minutes ?
eg: </p>

<pre><code>$date1="03/17/2012 9:00 PM";
    $date2=04/17/2012 9:40 PM";
</code></pre>

<p>then i want to show 12 hour and 40 minutes ?</p>

<p>How i will change the code now?</p>

<p>Please help me</p>
