0IV$htime=date("H:i",$time);
0V$time=time()-$time;
0VIif($time0VII$str=刚刚;
0VII" />

"景先生毕设|www.jxszl.com

织梦DEDE模板实现某小时前,某天前发布的时间标签代码

2022-10-29 16:36编辑: www.jxszl.com景先生毕设
在include/extend.func.php页面最下面增加如下代码:
/*
*AB模板
*文章发布多少时间前
0I.*/
0IIfunctiontranTime($time){
0III$rtime=date("m-dH:i",$time);

 更多精彩就在: 51免费论文网|www.jxszl.com 
r/>0IV$htime=date("H:i",$time);
0V$time=time()-$time;
0VIif($time0VII$str=刚刚;
0VIII}
0IXelseif($timeI.0$min=floor($time/VI0);
I.I.$str=$min.分钟前;
I.II}
I.IIIelseif($timeI.IV$h=floor($time/(VI0*VI0));
I.V$str=$h.小时前;
I.VI}
I.VIIelseif($timeI.VIII$d=floor($time/(VI0*VI0*IIIV));
I.IXif($d==I.)
II0$str=昨天;
III.else
IIII$str=前天;
IIIII}
IIIVelse{
IIV$str=$rtime;
IIVI}
IIVIIreturn$str;
IIVIII}

II.列表页调用标签如下:
[field:pubdatefunction="tranTime(@me)"/]

III.文章页调用标签如下:
{dede:field.pubdatefunction="tranTime(@me)"/}

原文链接:http://www.jxszl.com/biancheng/dedecms/75796.html