php时间 显示刚刚 几分钟前等?

功能示例:

$now = time();
foreach($sys_res as $k => $v){
$day = intval(floor(($now - $v->system_time)/86400));
$month = intval(floor(($now - $v->system_time)/(86400*30)));
$year = intval(floor(($now - $v->system_time)/(86400*30*12)));
if($year >= 1){
$v->day = $year . '年前';
}else if($month >=1 && $month < 12){
$v->day = $month . '月前';
}else{
if($day>= 1){
$v->day = $day . '天前';
}else if($day < 1){
$hour = intval(floor(($now - $v->system_time)/3600));
if($hour >= 1){
$v->day = $hour . '小时前';
}else if($hour < 1){
$minute = intval(floor(($now - $v->system_time)/60));
if($minute >= 1){
$v->day = $minute . '分钟前';
}else if($minute < 1){
$v->day = '刚刚';
}
}
}
}
$v->system_time = date('Y-m-d H:i:s',$v->system_time);
}