I have the following dates and I would like the difference in the format hh:mm:ss
.
I have the following code,
$from = "2019-05-20 23:59";
$to = "2019-05-27 00:00";
$expiry_time = new DateTime($to);
$current_date = new DateTime($from);
$diff = $expiry_time->diff($current_date);
return $diff->format('%H:%I:%S');
The above returns 00:01:00
, but I expect it to be 114:01:00
, since its 6 days (6*24 = 114
).
I have also tried
$from = "2019-05-20 23:59";
$to = "2019-05-27 00:00";
$time_diff = strtotime($to) - strtotime($from);
return date('H:i:s', $time_diff);
Which also gives 00:01:00
What am i missing? How can i convert this to show even beyond 24 hours? I have checked get time difference in hours minutes and seconds to no avail.