做出来的效果就是上面这样。
代码:
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
转载请注明原文地址: https://mac.8miu.com/read-75586.html