<script type="text/javascript">
var mydate=new Date();
var weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
document.write("今天是:" +weekday[mydate.getDate()] );
</script>
</head>
获取日期的方法是getDay(),而不是getDate()
var myDate = new Date();
var d = myDate.getDay();
switch (d) {
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 = "今天周六";
default:
}
document.write(str);
1164116435 可以一起学习
谢谢解答 找到问题了 头懵!我竟然写错Day写成了Date,,,愚蠢啊。
我刚刚看到这个日期知识点。
mydate.getDate()这里有问题吧,
getDay()返回的是0到6数字。
<script type="text/javascript">
var mydate=new Date();
var weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
document.write("今天是:" +weekday[mydate.getDay()] );
</script>