php计算时间差是什么时间之后

做出来的效果就是上面这样。

代码:

function timeformat($time){
    $day = $hour = $min = $sec = 0;
    $day  = floor($time/86400);
    $hour = floor(($time%86400)/3600);
    $min = floor(($time%3600)/60);
    $sec = $time%3600%60;
    $str = "";
    if ($day) $str.="{$day}天,";
    if ($hour) $str.="{$hour}小时,";
    if ($min)  $str.="{$min}分钟,";
    if ($sec)  $str.="{$sec}秒后";
    return $str;
}

$time参数为秒数。

原文地址:https://www.cnblogs.com/doubilaile/p/8351642.html