js时间脚本
window.onload=function(){ var time = new Date(); var year = time.getFullYear(); var month = time.getMonth()+1; if(month<10){ month="0"+month; } var day = time.getDate(); if(day<10){ day="0"+day; } var week = time.getDay(); switch(week){ case 0: week = "星期日"; break; case 1: week = "星期一"; break; case 2: week = "星期二"; break; case 3: week = "星期三"; break; case 4: week = "星期四"; break; case 5: week = "星期五"; break; case 6: week = "星期六"; break; } var h = time.getHours(); var m = time.getMinutes(); var s = time.getSeconds(); var now = year+"年"+month+"月"+day+"日"+"<br>"+week+"<br>"+h+"时"+m+"分"+s+"秒"+"<br>"; document.getElementById("time").innerHTML = now; } setInterval(getDate,1000);