在織夢(mèng)dedecms中,文章與分類(lèi)調(diào)用時(shí)間,是有參考范例的,但是如果在首頁(yè)或者在單頁(yè)顯示當(dāng)前時(shí)間如何處理呢? 比如像本站一樣的首頁(yè)顯示效果,某年某月某日。有朋友說(shuō)到用JS, 其實(shí)在dedecms中用一下代碼即可搞定:
{dede:mytime runphp='yes'}@me=date("Y年m月d日");$weekarray=array("日","一","二","三","四","五","六"); @me = date("Y年m月d日")." 星期".$weekarray[date("w")];
{/dede:mytime}
直接復(fù)制以上代碼,貼在要顯示的位置,如果是在首頁(yè),請(qǐng)讓首頁(yè)動(dòng)態(tài),非靜態(tài)哦! 不然靜態(tài)會(huì)顯示生成時(shí)候的時(shí)間!
以上是通過(guò)dedecms標(biāo)簽的方法,其實(shí)還有其他三種方法,再補(bǔ)充下
dede通過(guò) php獲取
{dede:php}
$GLOBALS['thisid'] = intval($refObj->Fields['id']);
{/dede:php}
js調(diào)用當(dāng)天是周幾:
<script language="JavaScript">
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i + 1] = initArray.arguments[i]
}
var d=new initArray("<font color=RED>星期日","<font color=black>星期一","<font color=black>星期二","<font color=black>星期三","<font color=black>星期四","<font color=black>星期五","<font color=red>星期六");
document.write(d[today.getDay()+1]);
</script>
js調(diào)用當(dāng)天日期:
<script language="JavaScript">
today=new Date();
document.write("<font color=black>",today.getFullYear(),"<font color=black>年","<font color=black>",today.getMonth()+1,"<font color=black>月","<font color=black>",today.getDate(),"<font color=black>日 </FONT>");
</script>