PHP 根据时间差得出时分秒

function secTime(int $time = 0){
if($time < 1) return '0秒';
$str = '';
if($time >= 3600){
$str .= floor($time / 3600) . '小时';
$time = $time % 3600;
}
if($time >= 60){
$str .= floor($time / 60) . '分钟';
$time = $time % 60;
}
if($time > 0){
$str .= $time . '秒';
}
return $str;
}

posted @ 2020-10-30 16:11  阿拉神苗  阅读(465)  评论(0编辑  收藏  举报