function time_trans($paratime,$suffix=false){ $now_time = time(); $dur = $now_time - $paratime; $suffix && $sustr = '前'; if($dur < 0){ return $time; }else{ if($dur < 60){ return $dur.'秒'.$sustr; }else{ if($dur < 3600){ return floor($dur/60).'分钟'.$sustr; }else{ if($dur < 86400){ return floor($dur/3600).'小时'.$sustr; }else{ if($dur < 259200){//3天内 return floor($dur/86400).'天'.$sustr; }else{ return $time; } } } } } }