title: PHP: Get difference between two DateTime objects in Hours, Minutes, and Seconds
body: <p>I'm trying to calculate the number of hours a person has worked on a given day. To do so, I need to get the difference between two DateTime objects in Hours, Minutes, and Seconds. So far I can successfully do so like this</p>
  
  <pre><code>        $timeIn        = new DateTime($time['timeIn']);
          $timeOut       = new DateTime($time['timeOut']);
          $time['hours'] = date_diff($timeIn, $timeOut) -&gt; format("%H:%i:%s");
  </code></pre>
  
  <p>This seems to work fine, until I put in a test case where the employee forgot to clock out. Now, let's say that </p>
  
  <pre><code>$timeIn  = '2016-09-28 14:26:17'
  $timeOut = '2016-09-30 09:53:53'
  </code></pre>
  
  <p>In that case, the difference SHOULD be 43:27:36 (Because there is over a day in between the timeIn and timeOut). Instead, I get 19:27:36 (as if it's just truncating the days off and returning the rest). How can I add that day onto the hours instead of truncating it? (I'm looking to get 43:27:36, NOT 1day, 19 hours, ect ect. So I'm trying to get the answer in HH:MM:SS)</p>