【帝国CMS】时间格式改成几分钟,几小时,几天前等插件
2017-10-21 15:57
567 查看
在网上试了好几个,终于通过各种组合,成功了一个,发出来给大家看看,同时六个备份,以便以后自己使用。在此还是得感觉懂代码的贡献者。不多说,放码。
把以下的内容复制到 /e/class/userfun.php 文件里,放在<?php和?>之间就可以了。
然后在帝国cms模版里放入相应的时间标签。
1、在标签模板、列表模板中的调用:
'.user_time($r[newstime],0).'
2、在内容页中调用:
<?=user_time($navinfor[newstime],0)?>
3、在评论JS调用模板调用方法:
在评论JS调用模板把
[!----pltime--]换成
<?=user_time($r[saytime],1)?>
然后打开e\pl\more\index.php ,找到:
具体信息,请查看:http://www.16css.com/ecms/934.html
把以下的内容复制到 /e/class/userfun.php 文件里,放在<?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模版里放入相应的时间标签。
1、在标签模板、列表模板中的调用:
'.user_time($r[newstime],0).'
2、在内容页中调用:
<?=user_time($navinfor[newstime],0)?>
3、在评论JS调用模板调用方法:
在评论JS调用模板把
[!----pltime--]换成
<?=user_time($r[saytime],1)?>
然后打开e\pl\more\index.php ,找到:
require("../../class/connect.php");下一行加入以下代码:
require("../../class/userfun.php");然后保存。
具体信息,请查看:http://www.16css.com/ecms/934.html
相关文章推荐
- js把字符串格式的时间转换成几秒前、几分钟前、几小时前、几天前等格式
- js时间格式转换为几天前几小时几分钟等
- 时间戳 得到(几分钟前,几小时前,几天前)
- 用javascript写一个显示时间差 几分钟前 几小时前 几天前 几周前 大于一个月显示日期
- 时间以几分钟、几小时前、几天前等时间差显示的js函数
- 把发表的时间改为几个月,几天前,几小时前,几分钟前,或几秒前
- ASP 格式化显示时间为几个月,几天前,几小时前,几分钟前,或几秒前
- NSDate 实现时间格式刚刚、几分钟前、几小时前、昨天、MM-dd HH:mm:ss
- iOS开发-显示发送时间(几分钟前,几小时前,几天前)
- ios 返回时间差 几分钟几小时几天前
- C# 格式化显示时间为几个月,几天前,几小时前,几分钟前,或几秒前
- 怎么计算几天前,几小时前,几分钟前,几周前,几个月前,几年前的时间?
- C#计算发表时间为几个月,几天前,几小时前,几分钟前,或几秒前
- js计算时间为刚刚、几分钟前、几小时前、几天前··
- asp.net 格式化显示时间为几个月,几天前,几小时前,几分钟前,或几秒前
- 把某个js时间转化为几天前,几小时前,几分钟前
- C#计算发表时间为几个月,几天前,几小时前,几分钟前,或几秒前
- js 时间戳转换成几分钟前,几小时前,几天前
- js时间转化为几天前,几小时前,几分钟前
- php把时间计算成几分钟前,几小时前,几天前的函数