<?php
function getFullHour($input) {
$seconds = intval($input); //Converte para inteiro
$negative = $seconds < 0; //Verifica se é um valor negativo
if ($negative) {
$seconds = -$seconds; //Converte o negativo para positivo para poder fazer os calculos
}
$hours = floor($seconds / 3600); $mins = floor(($seconds - ($hours * 3600)) / 60); $secs = floor($seconds % 60);
$sign = $negative ? '-' : ''; //Adiciona o sinal de negativo se necessário
return $sign . sprintf('%02d:%02d:%02d', $hours, $mins, $secs); }
echo getFullHour(685), PHP_EOL; //00:11:25
echo getFullHour(140801), PHP_EOL; //39:06:41
echo getFullHour(100800), PHP_EOL; //28:00:00
echo getFullHour(-140801), PHP_EOL; //-39:06:41
echo getFullHour(-100800), PHP_EOL; //-28:00:00
PD9waHAKZnVuY3Rpb24gZ2V0RnVsbEhvdXIoJGlucHV0KSB7CiAgICAkc2Vjb25kcyA9IGludHZhbCgkaW5wdXQpOyAvL0NvbnZlcnRlIHBhcmEgaW50ZWlybwoKICAgICRuZWdhdGl2ZSA9ICRzZWNvbmRzIDwgMDsgLy9WZXJpZmljYSBzZSDDqSB1bSB2YWxvciBuZWdhdGl2bwoKICAgIGlmICgkbmVnYXRpdmUpIHsKICAgICAgICAkc2Vjb25kcyA9IC0kc2Vjb25kczsgLy9Db252ZXJ0ZSBvIG5lZ2F0aXZvIHBhcmEgcG9zaXRpdm8gcGFyYSBwb2RlciBmYXplciBvcyBjYWxjdWxvcwogICAgfQoKICAgICRob3VycyA9IGZsb29yKCRzZWNvbmRzIC8gMzYwMCk7CiAgICAkbWlucyA9IGZsb29yKCgkc2Vjb25kcyAtICgkaG91cnMgKiAzNjAwKSkgLyA2MCk7CiAgICAkc2VjcyA9IGZsb29yKCRzZWNvbmRzICUgNjApOwoKICAgICRzaWduID0gJG5lZ2F0aXZlID8gJy0nIDogJyc7IC8vQWRpY2lvbmEgbyBzaW5hbCBkZSBuZWdhdGl2byBzZSBuZWNlc3PDoXJpbwoKICAgIHJldHVybiAkc2lnbiAuIHNwcmludGYoJyUwMmQ6JTAy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