当前位置 : 主页 > 网络编程 > PHP >

秒数转换成多少天/多少小时/多少分

来源:互联网 收集:自由互联 发布时间:2021-06-28
remain_days function get_stay_time($deadline, $is_hour = 1, $is_minutes = 1){ if(empty($deadline) || $deadline = 60) { return false; } $time = time(); $remain_time = $deadline - $time; $day = floor($remain_time / (3600*24)); $day = $day 0 ?
remain_days
function get_stay_time($deadline, $is_hour = 1, $is_minutes = 1)
{
    if(empty($deadline) || $deadline <= 60) {
        return false;
    }

    $time = time();
    $remain_time = $deadline - $time;

    $day = floor($remain_time / (3600*24));
    $day = $day > 0 ? $day.'天' : '';
    $hour = floor(($remain_time % (3600*24)) / 3600);
    $hour = $hour > 0 ? $hour.'小时' : '';
    if($is_hour && $is_minutes) {
        $minutes = floor((($remain_time % (3600*24)) % 3600) / 60);
        $minutes = $minutes > 0 ? $minutes.'分' : '';
        return $day.$hour.$minutes;
    }

    if($hour) {
        return $day.$hour;
    }
    return $day;
}
网友评论