title: PHP DateTime formatting works but DateInterval formatting not working
body: <p>I've got a bit of PHP code here that calculates (and echos out) a time duration. I have an if/else that chooses how to calculate the duration. Due to the way i have done the calculations, under one circumstance the duration that is output is a DateTime object, under the other it is a DateInterval object. The formatting of both is done outside the if/else statement.</p>
  
  <p>The calculations are working fine, and the formatting for the DateTime object are working fine, but the formatting for the DateInterval object is off. It shows percent signs within the output time (example at the end of the codeblock).</p>
  
  <pre><code>$time1 = new DateTime($row[0]); 
  $time2 = new DateTime($row[1]);
  
  if ($time1 &gt; $time2) { 
      $twentyFourHours = new DateTime('240000');
      $difference = $time1-&gt;diff($twentyFourHours);
      $time2-&gt;add($difference);
      $duration = $time2; // this is a DateInterval object
  }
  
  else    {
  $duration = $time2-&gt;diff($time1);  // This is a DateTime object
          }  
  
  echo $duration-&gt;format('%H:%I');
  echo '&lt;br&gt;';
  echo $row['2'];
      }
  </code></pre>
  
  <p>Below is an example of the output i am getting (every other duration is the DateInterval object with the percent signs):</p>
  
  <p>02:10<br>
  2016-06-16</p>
  
  <p>%12:%0<br>
  2016-06-16</p>
  
  <p>03:04<br>
  2016-06-17</p>
  
  <p>%12:%0<br>
  2016-06-17</p>
  
  <p>From what i can tell in the DateInterval formatting docs, i am setting the formatting correctly for two digit hours and two digit minutes ('%H:%I'), but the output would seem to prove otherwise. I am guessing i am overlooking something silly and would be grateful if someone could point out where i am going wrong.</p>
  
  <p>Many Thanks!</p>