帝国cms发布于10秒前 1周前 1个月前 倒计时函数设置方法
打开 /e/class/userfun.php 文件,
添加以下代码:
1 | 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."前"; } |
内容页调用:
1 | <?=user_ago($navinfor[newstime])?> |
列表內容模板(list.var) (*) 调用:
1 | $listtemp = "发布时间" .user_ago( $r [newstime]). "" ; |
上一篇:修复帝国CMS邮件标题乱码问题