美文网首页
实现显示多少分钟发帖的代码

实现显示多少分钟发帖的代码

作者: gianna1030 | 来源:发表于2017-08-17 22:48 被阅读0次

<?php
function tranTime($time) {
$rtime = date("m-d H:i",$time);
$htime = date("H:i",$time);

$time = time() - $time; 

if ($time < 60) { 
    $str = '刚刚'; 
} 
elseif ($time < 60 * 60) { 
    $min = floor($time/60); 
    $str = $min.'分钟前'; 
} //时间轴 www.jbxue.com
elseif ($time < 60 * 60 * 24) { 
    $h = floor($time/(60*60)); 
    $str = $h.'小时前 '.$htime; 
} 
elseif ($time < 60 * 60 * 24 * 3) { 
    $d = floor($time/(60*60*24)); 
    if($d==1) 
       $str = '昨天 '.$rtime; 
    else 
       $str = '前天 '.$rtime; 
} 
else { 
    $str = $rtime; 
} 
return $str; 

}

相关文章

网友评论

      本文标题:实现显示多少分钟发帖的代码

      本文链接:https://www.haomeiwen.com/subject/niforxtx.html