title: php adding and subtracting time
body: <p>Im attempting to code a little script that will work out hours.</p>
  
  <p>I would like a travel time, start time and a finish time. The problem I'm having is getting the total time.</p>
  
  <pre><code>$travel = $_POST['travel'];  // -- 1.00 (1 hour)
  $start = $_POST['start'];    // -- 7.30 
  $finish = $_POST['finish'];  // -- 16.00 
  </code></pre>
  
  <p>so the total time would be ( 16.00 - 7.30 ) + 1.00 = 9.5 hours</p>
  
  <p>But this doesn't work because 16.00 - 7.30 = 8.7, then plus the 1 = 9.7.</p>
  
  <p>I understand why its wrong, but not how to fix it. I cant change the time values to .50 for the half hour because the value is coming from a jquery plugin. Any help would be much appreciated.</p>
  
  <p>// update</p>
  
  <pre><code>$a = new DateTime($_POST['start']);
  $b = new DateTime($_POST['finish']);
  $interval = $a-&gt;diff($b);
  
  echo $interval-&gt;format("%H");
  </code></pre>
  
  <p>This works great, the only thing is how do I display hours and minutes e.g '9.00'</p>