温馨提示:本文共583个字,读完预计2分钟。
/**
* 评论消息
* @param $openid
* @param $data
*/
public function timeBefore($the_time)
{
$now_time = time();
$dur = $now_time – $the_time;
if ($dur < 0) {
return $the_time;
}
if ($dur < 60) {
return '刚刚';
}
if ($dur < 3600) {
return floor($dur / 60) . '分钟前';
}
if ($dur < 86400) {
return floor($dur / 3600) . '小时前';
}
if ($dur < 259200) {
return floor($dur / 86400) . '天前';
}
return date('m-d', $the_time);
}