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参数为秒数。

posted @ 2018-01-25 15:55  andyliud  阅读(88)  评论(0编辑  收藏  举报