Date.getDay()可以获取当前日是一周的第几天,0为星期日,1为星期一,依次类推。
</script>
<script language=JavaScript>
function currenttime(){
var now =new Date();
var week =now.getDay();
var str="";
switch (week) {
case 0:
str="星期日";break;
case 1:
str="星期一";break;
case 2:
str="星期二";break;
case 3:
str="星期三";break;
case 4:
str="星期四";break;
case 5:
str="星期五";break;
case 6:
str="星期六";break;
}
document.getElementById("htime").innerHTML=now.getFullYear()+'年'(now.getMonth()+1)+'月'+now.getDate()+'日'+now.getHours()+'时'+now.getMinutes()+'分'+now.getSeconds()+'秒 '+str;
}
setInterval("currenttime()", 1000);
</script>注意getDay()与getDate()的区别。