public function smarttimeFilter($time)
{
$diff = time() - $time;
if ($diff < 0) {
return $this->getServiceKernel()->trans('未来');
}
if ($diff == 0) {
return $this->getServiceKernel()->trans('刚刚');
}
if ($diff < 60) {
return $diff.$this->getServiceKernel()->trans('秒前');
}
if ($diff < 3600) {
return round($diff / 60).$this->getServiceKernel()->trans('分钟前');
}
if ($diff < 86400) {
return round($diff / 3600).$this->getServiceKernel()->trans('小时前');
}
if ($diff < 2592000) {
return round($diff / 86400).$this->getServiceKernel()->trans('天前');
}
if ($diff < 31536000) {
return date('m-d', $time);
}
return date('Y-m-d', $time);
}