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

mac2022-06-30  22

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

代码:

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

最新回复(0)