thinkphp比较两个时间戳之间消耗时间方法
代码如下
/**
* 计算两个时间戳之?
* @param $begin_time
* @param $end_time
* @return array
*/
public function timeDiff( $begin_time, $end_time ){
if ( $begin_time < $end_time ) {
$starttime = $begin_time;
$endtime = $end_time;
} else {
$starttime = $end_time;
$endtime = $begin_time;
}
$timediff = $endtime - $starttime;
$days = intval( $timediff / 86400 );
$remain = $timediff % 86400;
$hours = intval( $remain / 3600 );
$remain = $remain % 3600;
$mins = intval( $remain / 60 );
$secs = $remain % 60;
$res = array( "day" => $days, "hour" => $hours, "min" => $mins, "sec" => $secs );
return $res;
}
版权声明:
作者:超级管理员
链接:
https://blog.apecloud.ltd/article/detail.html?id=4
来源:猿码云个人技术站
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
打赏


共有0条评论