- print_r: documentation ( source)
- json_encode: documentation ( source)
<?php
$dateinterval = new DateInterval('PT1H');
print_r($dateinterval);
echo "\n";
echo json_encode($dateinterval);
echo "\n";
$string = $dateinterval->format('%y years %m months %d days %h hours %i minutes %s seconds');
echo $string;
echo "\n";
$dateinterval2 = DateInterval::createFromDateString($string);
$string2 = $dateinterval2->format('%y years %m months %d days %h hours %i minutes %s seconds');
echo $string;