function mtime($time=NULL){ $text =""; $times = NULL==$time || $time==time() ? $time : intval($time); $t = time()-$times; if($t==0){ $text="刚刚"; }elseif ($t<60) { $text=$t."秒前"; }elseif ($t<3600) { $text=floor($t/60)."分钟之前"; }elseif ($t<60*60*24) { $text=floor($t/3600)."小时之前"; }elseif ($t<60*60*24*3) { $text=floor($text/60*60*24)==1?"昨天".date("H:i",$time):"前天".date("H:i",$time); }elseif ($t<60*60*24*30) { $text = date('m月d日 H:i',$times);//一个月内 }elseif ($t<60*60*24*30*365) {//一年内 $text = date("m月d日",$times); }else{//一年前 $text = date("Y年前",$times); } return $text;}