php 把秒數轉換爲時長(h:i:s格式)

/**
 *      把秒數轉換爲時分秒的格式
 *      @param Int $times 時間,單位 秒
 *      @return String
 */
function secToTime($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 = $hour.':'.$minute.':'.$second;
        }
        return $result;
}



轉載自:http://www.hblpf.com/?post=106

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章