二款js 年月日星期显示代码
<SCRIPT language=javascript教程>
function showDate()
{
var d = new Date();
document.write("<div class="date_div">"+d.getYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日");
switch(d.getDay())
{
case 0:
document.write(" 星期日");
break;
case 1:
document.write(" 星期一");
break;
case 2:
document.write(" 星期二");
break;
case 3:
document.write(" 星期三");
break;
case 4:
document.write(" 星期四");
break;
case 5:
document.write(" 星期五");
break;
case 6:
document.write(" 星期六");
break;
}
document.write("</div>");
}
</script>
<script language="JavaScript" type="text/JavaScript">
showDate();
</script>
第二款js 日期显示
<SCRIPT language=JavaScript>
<!---
today=new Date();
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(" 星期日"," 星期一"," 星期二"," 星期三"," 星期四"," 星期五"," 星期六"); document.write(today.getYear(),"年","",today.getMonth()+1,"月",today.getDate(),"日",d[today.getDay()+1]); //-->
</SCRIPT>