织梦园模板网提供云优cms模板,pbootcms模板,Wordpress主题模板等各类企业新闻资讯网站模板下载服务。织梦园网站模板交流群
用户名:
密码:
注册
注册后享受折扣价

织梦模板DedeCms时间格式调用汇总

织梦园模板 / 2018-12-23 / 收藏

  织梦DedeCMS确实是一款很强大的CMS建站软件。学好织梦的各种调用,制作各种网站都是可以的了。今天主要搜集了一些织梦时间格式调用的标签。我们在使用织梦DedeCms的过程中,会根据需要改变时间的显示样式,达到各种想要的效果。下面整理了一些常用的时间格式,供大家参考。

  先是各种时间格式,注释部分为示例。


{dede:field name='pubdate' function='strftime("%Y年%m月%d日 %H:%M:%S","@me")' /}
// 2007年1月1日 18:30:02

{dede:field name='pubdate' function='strftime("%Y-%m-%d %H:%M:%S","@me")'
//2007-1-1 18:30:02

{dede:field name='pubdate' function='strftime("%Y年%m月%d日 %H时%M分%S秒","@me")' /}
//2007年1月1日 18时30分02秒

{dede:field name='pubdate' function='strftime("%m-%d %H:%M:%S","@me")' /}
//1-1 18:30:02

{dede:field name='pubdate' function='strftime("%m-%d","@me")' /}
//1-1
这其中我们只要了解%Y-年、%m-月、%d-日、%H-小时、%M-分、%S-秒之间的对应关系,就可以自由组合了。
下面是一个时间格式的特效,即24小时内的时间显示红色。代码如下:

[field:pubdate runphp='yes']

$a="<font color='#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]
当然,你把颜色代码#ff0000改为任意你想要的颜色,就可以实现24小时内发表文章时间显示任意颜色了。

  以下是***后更新时间的时间格式代码:

{dede:tagname runphp='yes'}@me = date("Y-m-d H:i:s",time());{/dede:tagname}
以下是XX天前的时间格式代码:
[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]
  这段代码的意思是表示文章是多少天前更新的。掌握了以上的织梦时间格式调用,做出各种织梦文章更新时间等的效果是充足了,你可以把以上的代码进行任意的组合使用。

相关标签调用

收缩