
经常使用时间格式编码。下面分享一下所有相关代码。
1.时间格式{dede:fieldname='pubdate'function='strftime("%Y年%m月%d日%H:%M:%S","@me")'/}2007年1月1日18:30:02
{dede:fieldname='pubdate'function='strftime("%Y-%m-%d%H:%M:%S","@me")'/}2007-1-118:30:02
{dede:fieldname='pubdate'function='strftime("%Y年%m月%d日%H时%M分%S秒","@me")'/}2007年1月1日18时30分02秒
{dede:fieldname='pubdate'function='strftime("%m-%d%H:%M:%S","@me")'/}1-118:30:02
{dede:fieldname='pubdate'function='strftime("%m-%d","@me")'/}1-1
%Y-年
%m-月
%d-日
%H-钟头
%M-分
%S-秒
2.24小时内的时间显示红色..
[field:pubdaterunphp='yes']
$a="<fontcolor='#ff0000'>";
$b="</font>";
$c=strftime("%Y年%m月%d日%H:%M:%S","@me");
$ntime=time();
$oneday=3600*24;
if(($ntime-@me)<$oneday)@me=$a.$c.$b;
else@me=$c;
[/field:pubdate]
3.最终更新
最终更新:{dede:tagnamerunphp='yes'}@me=date("Y-m-dH:i:s",time());{/dede:tagname}
4.XX天内
[field:pubdaterunphp='yes']
$today=Floor(time()/(3600*24));
$senday=Floor(@me/(3600*24));
$updays=$today-$senday;
if($updays==0)@me="今日";
else@me=$updays."天内";
[/field:pubdate]
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)