dedecms(织梦)时间日期标签样式调用大全
24小时内更新的文章时间显示为红色:
[field:pubdate runphp=’yes’]
$a=”<font color=red>”.strftime(‘%m-%d’,@me).”</font>”;
$b=strftime(‘%m-%d’,@me);
$ntime = time();
$c = 3600 * 24;
if(($ntime – @me) < $c) @me = $a;
else @me =$b;
[/field:pubdate]
[field:pubdate runphp=’yes’]$aa=strftime(‘%m-%d’,@me);$ntime = time();$tagtime = @me;$day3 = 3600 * 24;if($tagtime > $ntime-$day3) @me = “<font color=’red’>(new)</font>”;else @me = $aa;[/field:pubdate]
24小时内更新的文章时间后面添加加new.gif小图片:
[field:pubdate runphp=’yes’]$aa=strftime(‘%m-%d’,@me);$ntime = time();$tagtime = @me;$day3 = 3600 * 24 * 3;if($tagtime > $ntime-$day3) @me = “<img src=’new.gif’ />”.$aa;else @me = $aa;[/field:pubdate]
24小时内更新的文章只显示时间不日期,不在24小时内则显示日期不显示时间:
[field:pubdate runphp=”yes”]if((time()-@me)<(60*60*24)){@me=’ <font color=”#ff6600″>’.strftime(“%H:%M”,@me).'</FONT>’;}else {@me=strftime(“%m-%d”,@me);}[/field:pubdate]
人性化的 时间格式,显示几天前,而不显示日期:
[field:pubdate runphp=’yes’]
$today = Floor(time()/(3600 * 24));
$senday= Floor(@me/(3600 * 24));
$updays = $today-$senday;
if($updays==0) @me = “今日”;
else @me = $updays.”天前”;
[/field:pubdate]
更人性化的时间格式,在规定日期内显示今天、昨天、明天之类的,规定时间外则显示日期:
[field:pubdate runphp=’yes’]
$today = Floor(time()/(3600 * 24));
$b=strftime(“%m月%d日”,”@me”);
$a= Floor(@me/(3600 * 24));
$days = $today-$a;
if($days==0) @me = “<font color=’#0000FF’>今日</font>”;
elseif($days==1) @me = “<font color=’#00CC66′>昨天</font>”;
elseif($days==2) @me = “<font color=’#00CC66′>前天</font>”;
elseif($days==-1) @me = “<font color=’#ff0000′>明天</font>”;
elseif($days==-2) @me = “<font color=’#ff0000′>后天</font>”;
else @me = $b;
[/field:pubdate]
此格式适合自定义时间字段
PS:以上$a、$b、$c、$*都是为自定义函数,也就是什么字母都OK。
%Y-年(四位) %y-年(后两位) %m-月 %d-日 %H-小时 %M-分 %S-秒
如果你发现有更多的是时间格式,欢迎联系我,让我加上!