This can be achieved with DateTime
class
Function:
function secondsToTime($seconds) {
$dtF = new DateTime('@0');
$dtT = new DateTime("@$seconds");
return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds');
}
Use:
echo secondsToTime(1640467);
# 18 days, 23 hours, 41 minutes and 7 seconds
demo
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…