Source Code:
(back to article)
$start = new DateTime('2022-01-01 10:00:00'); $end = new DateTime('2022-01-01 11:30:00'); $diff_in_seconds = $end->getTimestamp() - $start->getTimestamp(); $minutes = floor($diff_in_seconds / 60); $seconds = $diff_in_seconds % 60; $formatted_diff = sprintf('%d.%02d', $minutes, $seconds); echo $formatted_diff; // output: 90.00
Result:
Report an issue