Normalize DateInterval in PHP



PHP Snippet 1:

echo (new DateTime('@0'))->add(new DateInterval("PT6000S"))->format('h:i');
// 01:40

PHP Snippet 2:

//360000 Sec = 100 hours = 4 Days + 4 hours
$di = new DateInterval("PT360000S");

$diNormalize = date_create('@0')->diff(date_create('@0')->add($di));

var_export($diNormalize);
/*
DateInterval::__set_state(array(
   'y' => 0,
   'm' => 0,
   'd' => 4,
   'h' => 4,
   'i' => 0,
   's' => 0,
   'f' => 0.0,
   'weekday' => 0,
   'weekday_behavior' => 0,
   'first_last_day_of' => 0,
   'invert' => 0,
   'days' => 4,
   'special_type' => 0,
   'special_amount' => 0,
   'have_weekday_relative' => 0,
   'have_special_relative' => 0,
)) 
*/

echo $diNormalize->format('%a days %h hours %i minutes');
//4 days 4 hours 0 minutes