成都创新互联网站制作重庆分公司

php将时间戳转换为多少分钟前

foreach ($comments as $k => &$v){

    $s =  (int)($nowtime-$v['create_time']);

    if((0<$s) && ($s<60)){
         $v['time_num'] = $s.'秒前';
    }elseif((60<$s) && ($s<3600)){
        $mins = $s/60;
        $v['time_num'] = floor($mins).'分钟前';
    }elseif((3600<$s) && ($s<86400)){
          $hours = $s/3600;
          $v['time_num'] = floor($hours).'小时前';
    }elseif($s>=86400) {
        $days = $s / 86400;
        $v['time_num'] = floor($days) . '天前';
    }
}

网站名称:php将时间戳转换为多少分钟前
网页URL:http://cxhlcq.com/article/ghdgej.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部