文章介紹
學(xué)好織夢(mèng)的各種調(diào)用,制作各種網(wǎng)站都是可以的了??棄?mèng)DedeCMS確實(shí)是一款很強(qiáng)大的CMS建站軟件。今天主要搜集了一些織夢(mèng)時(shí)間格式調(diào)用的標(biāo)簽。我們?cè)谑褂?a href="http://mengdiqiu.com.cn/">織夢(mèng)模板的過程中,會(huì)根據(jù)需要改變時(shí)間的顯示樣式,達(dá)到各種想要的效果。下面整理了一些常用的時(shí)間格式,供大家參考?! ∠仁歉鞣N時(shí)間格式,注釋部分為示例。
{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時(shí)%M分%S秒","@me")' /}
//2007年1月1日 18時(shí)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-小時(shí)、%M-分、%S-秒之間的對(duì)應(yīng)關(guān)系,就可以自由組合了?! ∠旅媸且粋€(gè)時(shí)間格式的特效,即24小時(shí)內(nèi)的時(shí)間顯示紅色。代碼如下:
[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]
當(dāng)然,你把顏色代碼#ff0000改為任意你想要的顏色,就可以實(shí)現(xiàn)24小時(shí)內(nèi)發(fā)表文章時(shí)間顯示任意顏色了。
以下是最后更新時(shí)間的時(shí)間格式代碼:
{dede:tagname runphp='yes'}@me = date("Y-m-d H:i:s",time());{/dede:tagname}
以下是XX天前的時(shí)間格式代碼:
[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]
這段代碼的意思是表示文章是多少天前更新的。掌握了以上的織夢(mèng)時(shí)間格式調(diào)用,做出各種織夢(mèng)文章更新時(shí)間等的效果是充足了,你可以把以上的代碼進(jìn)行任意的組合使用。如果你在織夢(mèng)的時(shí)間格式調(diào)用上有什么疑問或者看法,歡迎在本文后面留言,會(huì)盡量給大家答疑的。