打开 /e/class/userfun.php 文件,
添加以下代码:
function user_ago($tm,$rcs = 0) {
$cur_tm = time();
$dif = $cur_tm-$tm;
$pds = array('秒','分钟','小时','天','周','个月','年');
$lngh = array(1,60,3600,86400,604800,2630880,31570560);
for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--);
if($v < 0) $v = 0;
$_tm = $cur_tm-($dif%$lngh[$v]);
$no = floor($no);
//if($no <> 1) $pds[$v] .='s';
//+s
$x=sprintf("%d %s",$no,$pds[$v]);
if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0))
$x .= time_ago($_tm);
return $x."前";
}
内容页调用:
<?=user_ago($navinfor[newstime])?>
列表內容模板(list.var) (*) 调用:
$listtemp = "发布时间".user_ago($r[newstime])."";