时间:2018年07月30日 | 作者 : angelsea | 分类 : 小海分享 | 浏览: 200次 | 评论 0 人
\phpcms\libs\functions\extention.func.php
extention.func.php 用户自定义函数库内增加如下代码:
function inputtime_zone($inputtime) { $input_now=time(); $input_time = $input_now-$inputtime; $input_hour = (int)($input_time/(60*60)); //小时 $input_day = (int)($input_time/(60*60*24)); //天 $input_min = (int)($input_time%(60*60)/60); //分钟 $input_week = (int)($input_time/(7*24*60*60)); //星期 $input_moon = (int)($input_time/(30*24*60*60)); //月份 if ($input_time < 300) { return '刚刚'; } elseif ($input_hour < 1) { return $input_min.'分钟前'; } elseif ($input_hour < 24 && $input_hour >= 1) { return $input_hour.'小时前'; } elseif ($input_hour >= 24 && $input_day <= 7) { return $input_day.'天前'; } elseif ($input_day > 7 && $input_day <= 30) { return $input_week.'个星期前'; } elseif ($input_day > 30 && $input_day <= 365) { return $input_moon.'个月前'; } else { return date('Y-m-d',$inputtime); } }
然后修改调用时间的标签为:{inputtime_zone($r[inputtime])}
PS:红色r需要注意下,这个按照你标签书写的loop里$r而来,如果是$v就要也改成v,其他亦然
推荐您阅读更多有关于“phpcms v9,”的文章
Powered By www.Xiaohai.cc
小海 版权所有. Rights Reserved
额 本文暂时没人评论 来添加一个吧
发表评论