//格式化时间
public static function getTime($time){
if(!empty($time)){
$dqTime=time();
if($dqTime>$time){
$t=$dqTime-$time;
$m=60;
$f=60*60;
$x=24*60*60;
if($t<$m){
$show=gmdate('s',$t).'秒前';
}elseif ($t<$f) {
$show=gmdate('i',$t).'分钟前';
}elseif ($t<$x) {
$show=gmdate('H',$t).'小时前';
}else{
$show=Helper::truncate_utf8_string(date('Y-m-d',$time),5,false);
}
return $show;
}else{
return false;
}
}else{
return false;
}
}
public static function format_date($date,$isShowDate=true) {
$limit = time() - $date;
if($limit < 60){
return $limit . '秒钟之前';
}
if($limit >= 60 && $limit < 3600){
return floor($limit/60) . '分钟之前';
}
if($limit >= 3600 && $limit < 86400){
return floor($limit/3600) . '小时之前';
}
if($limit >= 86400 and $limit<259200){
return floor($limit/86400) . '天之前';
}
if($limit >= 259200 and $isShowDate){
return date('Y-m-d', $date);
}else{
return '';
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
