把下面代码放到主题的module.php文件中<?php //日期格式化 function ea_timeago($ptime) { $ptime = strtotime($ptime)
<?php //日期格式化 function ea_timeago($ptime) { $ptime = strtotime($ptime); $etime = time() - $ptime; if ($etime < 1) return '刚刚'; $interval = array ( 12 * 30 * 24 * 60 * 60 => date('Y-m-d', $ptime), 30 * 24 * 60 * 60 => date('m-d', $ptime), 7 * 24 * 60 * 60 => date('m-d', $ptime), 24 * 60 * 60 => '天前', 60 * 60 => '小时前', 60 => '分钟前', 1 => '秒前' ); foreach ($interval as $secs => $str) { if ($etime < 7 * 24 * 60 * 60){ $d = $etime / $secs; if ($d >= 1) { $r = round($d); return $r . $str; } } else { return $str; } }; }?>
list_log.php 列表页调用代码:
<?php echo ea_timeago(timeago(gmdate('Y-m-d', $value['date']))); ?>
echo_log.php 文章阅读页调用代码:
<?php echo ea_timeago(gmdate('Y-n-j', $date)); ?>
粉丝
0
关注
0
收藏
0