What are the best practices for displaying time differences in human-readable format in PHP?

When displaying time differences in human-readable format in PHP, it's best to use the DateTime class to calculate the time difference and format it in a user-friendly way. This can be achieved by creating two DateTime objects representing the start and end times, calculating the difference between them, and then formatting the result using the DateInterval class.

$start = new DateTime('2022-01-01 12:00:00');
$end = new DateTime('2022-01-01 14:30:00');
$interval = $start->diff($end);

echo $interval->format('%h hours %i minutes');