/**
 * 时长转换
 *
 * @param string $timediff 秒数
 * @param integer $is_hour
 * @param integer $is_minutes
 * @return void
 */
function getTimeHour($timediff = '', $is_hour = 1, $is_minutes = 1)
{
    if (empty($timediff) || $timediff <= 60) {
        return '';
    }
    $day = floor($timediff / (3600 * 24));
    $day = $day > 0 ? $day . '天' : '';
    $hour = floor(($timediff % (3600 * 24)) / 3600);
    $hour = $hour > 0 ? $hour . '小时' : '';
    if ($is_hour && $is_minutes) {
        $minutes = floor((($timediff % (3600 * 24)) % 3600) / 60);
        $minutes = $minutes > 0 ? $minutes . '分钟' : '';
        return $day . $hour . $minutes;
    }

    if ($hour) {
        return $day . $hour;
    }
    return $day;
}

 

 posted on 2020-10-17 16:13  三哥-Noble  阅读(1114)  评论(0编辑  收藏  举报
TOP