Carbon Difference in Time between two Dates in hh:mm:ss format

I ended up grabbing the total seconds difference using Carbon:

$totalDuration = $finishTime->diffInSeconds($startTime);
// 21

Then used gmdate:

gmdate('H:i:s', $totalDuration);
// 00:00:21

If anyone has a better way I’d be interested. Otherwise this works.

Leave a Comment