0

have the following code where I get the difference between two hours, but in this case the difference is negative

$min_date = '18:40:00';
$hora_termino  = '16:30:00';

$dif_min       = new DateTime($hora_termino);
$dif_max       = new DateTime($time_min);
$result        = $dif_min->diff($dif_max);
$result_end    = $result->h + $result->i / 60;
echo $result_end /* 2.16*/

This result should be -2.16. Some form that diff that shows results negatively.

MoteCL
  • 228
  • 3
  • 20
  • [Does this answer your question?](https://stackoverflow.com/questions/327429/whats-the-best-way-to-calculate-date-difference-in-javascript) - or at least get you closer? –  May 13 '20 at 22:29
  • `$result_end = ($result->h + $result->i / 60) * ($result->invert ? -1 : 1);` this would help – MoteCL May 14 '20 at 13:15

0 Answers0