js代码:
<script type="text/javascript">
var today = new Date();
var week; //存储星期几
var date; //存储日期
switch (today.getDay()) {
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;
default:
week = "未知";
break;
}
date = (today.getFullYear()) + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日" + " ";
document.write(date + week); //将日期打印到body
</script>