PHP将秒数转换为时间(年、天、小时、分、秒)

/**
 * @param $time
 * @return bool|string
 * 将秒数转换为时间(年、天、小时、分、秒)
 */
function Sec2Time($times){
    $result = '00:00:00';
    if ($times>0) {
        $hour = floor($times/3600);
        $minute = floor(($times-3600 * $hour)/60);
        $second = floor((($times-3600 * $hour) - 60 * $minute) % 60);
        $result = sprintf ( "%02d",$hour).':'.sprintf ( "%02d",$minute).':'.sprintf ( "%02d",$second);
    }
    return $result;
}

 

© 版权声明
THE END
喜欢就支持一下吧
分享