/**
* 计算距离当前多久前
* @param $the_time
* @return string
*/
public static function timeTran($the_time)
{
$now_time = time();
$show_time = $the_time;
$dur = $now_time - $show_time;
if ($dur < 0) {
return '刚刚';
} else {
if ($dur < 60) {
return '刚刚';
} else {
if ($dur < 3600) {
return floor($dur / 60) . '分钟前';
} else {
if ($dur < 86400) {
return floor($dur / 3600) . '小时前';
} else {
if ($dur < 259200) {//3天内
return floor($dur / 86400) . '天前';
} else {
return date('m-d', $the_time);
}
}
}
}
}
}
php 计算距离当前多久前
于 2021-10-20 11:35:42 首次发布