186 words
1 minute
emlog 日期格式化代码 – -
2025-11-11
No Tags

tags: [] tags: []

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

emlog 日期格式化代码 – -
https://fuwari.vercel.app/posts/post_103/
Author
Lorem Ipsum
Published at
2025-11-11
License
CC BY-NC-SA 4.0