<?php
function dtLength($sec)
{
$t=new DateTime("@".$sec);
$r=new DateTime("@0");
$i=$t->diff($r);
return $h.":".$i->format("%I:%S");
}
$date = new DateTime;
$tempo_1 = 10 * 3600; // 10 horas
$tempo_2 = 18 * 3600; // 18 horas
$tempo_3 = 28 * 3600; // 28 horas
echo $date->setTime(0, 0, $tempo_1)->format('H:i:s'); // 10:00:00
echo $date->setTime(0, 0, $tempo_2)->format('H:i:s'); // 18:00:00
echo $date->setTime(0, 0, $tempo_3)->format('H:i:s'); // 04:00:00
echo dtLength($tempo_1);
echo dtLength($tempo_2);
echo dtLength($tempo_3);
PD9waHAKCmZ1bmN0aW9uIGR0TGVuZ3RoKCRzZWMpCnsKICAgICR0PW5ldyBEYXRlVGltZSgiQCIuJHNlYyk7CiAgICAkcj1uZXcgRGF0ZVRpbWUoIkAwIik7CiAgICAkaT0kdC0+ZGlmZigkcik7CiAgICAkaD1pbnR2YWwoJGktPmZvcm1hdCgiJWEiKSkqMjQraW50dmFsKCRpLT5mb3JtYXQoIiVIIikpOwogICAgcmV0dXJuICRoLiI6Ii4kaS0+Zm9ybWF0KCIlSTolUyIpOwp9CgokZGF0ZSA9IG5ldyBEYXRlVGltZTsKCiR0ZW1wb18xID0gIDEwICogMzYwMDsgLy8gMTAgaG9yYXMKCiR0ZW1wb18yID0gMTggKiAzNjAwOyAvLyAxOCBob3JhcwoKJHRlbXBvXzMgPSAyOCAqIDM2MDA7IC8vIDI4IGhvcmFzCgoKZWNobyAkZGF0ZS0+c2V0VGltZSgwLCAwLCAkdGVtcG9fMSktPmZvcm1hdCgnSDppOnMnKTsgLy8gMTA6MDA6MDAKCmVjaG8gJGRhdGUtPnNldFRpbWUoMCwgMCwgJHRlbXBvXzIpLT5mb3JtYXQoJ0g6aTpzJyk7IC8vIDE4OjAwOjAwCgplY2hvICRkYXRlLT5zZXRUaW1lKDAsIDAsICR0ZW1wb18zKS0+Zm9ybWF0KCdIOmk6cycpOyAvLyAwNDowMDowMAoKZWNobyBkdExlbmd0aCgkdGVtcG9fMSk7CmVjaG8gZHRMZW5ndGgoJHRlbXBvXzIpOwplY2hvIGR0TGVuZ3RoKCR0ZW1wb18zKTs=