您好,欢迎来到创立网络工作室官方网站!ZJJCL.CN
新闻动态
您现在的位置:首页 > 技术文摘
帝国cms7.5版本实现发布时间为:几小时前、几天前等格式的方法,帝国
来源:创立工作室 作者:冯军 发布时间:2020-07-25 10:41:01 阅读 715 次

...帝国cms7.5怎样实现时间为:几小时前、几天前等格式 帝国CMS调用昨天更新的文章 将以下代码放到:userfun.php

之间

function user_time($tm,$num) {
if($num==1){
   $tm =  strtotime($tm);
} 
   $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); 
   $x=sprintf("%d%s",$no,$pds[$v]);
   return $x."前";
}

帝国cms最新版本 列表模板调用:'.user_time($r[newstime],0).' (注:如果不会列表放代码,请看wareelll 在11楼的提示) 帝国cms模板网对《帝国cms7.2版本实现发布时间为:几小时前、几天前等格式的方法》总结来说,为我们企业网站建设很实用。

帝国cms7.5 所有官方插件 内容模板调用:

<?=user_time($bqr[newstime],"Y-m-d")?>