|
@@ -71,7 +71,7 @@ class Topicdongtai extends Api
|
|
|
$val['images_thumb'] = join('.', $images_url) . '_0.jpg';
|
|
|
}
|
|
|
|
|
|
- $val['createtime_text'] = $this->get_last_time($val['createtime']);
|
|
|
+ $val['createtime_text'] = get_last_time($val['createtime']);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -142,7 +142,7 @@ class Topicdongtai extends Api
|
|
|
unset($images_url[count($images_url) - 1]);
|
|
|
$info['images_thumb'] = join('.', $images_url) . '_0.jpg';
|
|
|
}
|
|
|
- $info['createtime_text'] = $this->get_last_time($info['createtime']);
|
|
|
+ $info['createtime_text'] = get_last_time($info['createtime']);
|
|
|
|
|
|
//评论
|
|
|
$info['answernumber'] = Db::name('topic_dongtai_answer')->where(['dt_id'=>$id,'level'=>1])->count();
|
|
@@ -340,7 +340,7 @@ class Topicdongtai extends Api
|
|
|
}
|
|
|
|
|
|
//时间处理
|
|
|
- $val['createtime_text'] = $this->get_last_time($val['createtime']);
|
|
|
+ $val['createtime_text'] = get_last_time($val['createtime']);
|
|
|
|
|
|
//回复是否已赞
|
|
|
$val['is_good'] = $this->answer_is_good($val['id'],$this->auth->id);
|
|
@@ -361,7 +361,7 @@ class Topicdongtai extends Api
|
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
|
->where(['a.id'=>$answer_id])->find();
|
|
|
$floor_info = info_domain_image($floor_info,['avatar']);
|
|
|
- $floor_info['createtime_text'] = $this->get_last_time($floor_info['createtime']);
|
|
|
+ $floor_info['createtime_text'] = get_last_time($floor_info['createtime']);
|
|
|
//回复是否已赞
|
|
|
$floor_info['is_good'] = $this->answer_is_good($answer_id,$this->auth->id);
|
|
|
$floor_info['answernumber'] = Db::name('topic_dongtai_answer')->where(['dt_id'=>$floor_info['dt_id'],'floor'=>$floor_info['floor'],'level'=>2])->count();
|
|
@@ -377,7 +377,7 @@ class Topicdongtai extends Api
|
|
|
if(!empty($child_lists)){
|
|
|
foreach($child_lists as $key => &$answer){
|
|
|
$answer['is_good'] = $this->answer_is_good($answer['id'],$this->auth->id);
|
|
|
- $answer['createtime_text'] = $this->get_last_time($answer['createtime']);
|
|
|
+ $answer['createtime_text'] = get_last_time($answer['createtime']);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -435,7 +435,7 @@ class Topicdongtai extends Api
|
|
|
$val['isgood'] = $this->is_good($val['id'],$this->auth->id);
|
|
|
|
|
|
//时间
|
|
|
- $val['createtime_text'] = $this->get_last_time($val['createtime']);
|
|
|
+ $val['createtime_text'] = get_last_time($val['createtime']);
|
|
|
|
|
|
//关注
|
|
|
$val['is_follow'] = $this->is_follow($val['user_id'],$this->auth->id);
|
|
@@ -448,45 +448,5 @@ class Topicdongtai extends Api
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 评论时间转换
|
|
|
- * @param null $time
|
|
|
- * @return false|string
|
|
|
- */
|
|
|
- private function get_last_time($time = NULL) {
|
|
|
- $text = '';
|
|
|
- $time = $time === NULL || $time > time() ? time() : intval($time);
|
|
|
- $t = time() - $time; //时间差 (秒)
|
|
|
- $y = date('Y', $time)-date('Y', time());//是否跨年
|
|
|
- switch($t){
|
|
|
- case $t == 0:
|
|
|
- $text = '刚刚';
|
|
|
- break;
|
|
|
- case $t < 60:
|
|
|
- $text = $t . '秒前'; // 一分钟内
|
|
|
- break;
|
|
|
- case $t < 60 * 60:
|
|
|
- $text = floor($t / 60) . '分钟前'; //一小时内
|
|
|
- break;
|
|
|
- case $t < 60 * 60 * 24:
|
|
|
- $text = floor($t / (60 * 60)) . '小时前'; // 一天内
|
|
|
- break;
|
|
|
- case $t < 60 * 60 * 24 * 3:
|
|
|
- $text = floor($time/(60*60*24)) ==1 ?'昨天 ' . date('H:i', $time) : '前天 ' . date('H:i', $time) ; //昨天和前天
|
|
|
- break;
|
|
|
- case $t < 60 * 60 * 24 * 30:
|
|
|
- $text = date('m月d日 H:i', $time); //一个月内
|
|
|
- break;
|
|
|
- case $t < 60 * 60 * 24 * 365&&$y==0:
|
|
|
- $text = date('m月d日', $time); //一年内
|
|
|
- break;
|
|
|
- default:
|
|
|
- $text = date('Y年m月d日', $time); //一年以前
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- return $text;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
}
|