Welcome to Delicate template
Header
Just another WordPress site
Header

js显示日期和星期

6月 9th, 2011 | Posted by 无 名 in js

用js显示当前时间的年月日和星期,兼容火狐。

<script language=JavaScript1.3> var version = 1.3;</script>
<script language="JavaScript">
<!--
var y=new Date();  
var gy=y.getYear();  
var dName=new Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六");  
var mName=new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");  
if (version < 1.3)  
{  
if (gy<2000)  
{  
document.write("<FONT COLOR='black' class='p1'>"+"19"+y.getYear()+"年" + mName[y.getMonth()] + y.getDate() + "日" + dName[y.getDay()] + "" + "</FONT>");  
}  
else  
document.write("<FONT COLOR='black' class='p1'>"+y.getYear()+"年" + mName[y.getMonth()] + y.getDate() + "日" + dName[y.getDay()] + "" + "</FONT>");  
}  
else  
{  
document.write("<FONT COLOR='black' class='p1'>"+y.getFullYear() +"年"+ mName[y.getMonth()] + y.getDate() + "日" + dName[y.getDay()] + "</FONT>");  
}  
//-->
</script>

You can follow any responses to this entry through the RSS 2.0 Both comments and pings are currently closed.