JavaScript进阶篇 7-23编程练习
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<script type="text/javascript">
//通过javascript的日期对象来得到当前的日期,并输出。
var myDate = new Date();
var weekDays = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
document.write(myDate.getFullYear() + "年" + myDate.getMonth() + "月" + myDate.getDay() + "日" + weekDays[myDate.getDay()]);
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<script type="text/javascript">
var mydate = new Date();
var i = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
document.write("今天是阳历:"+mydate.getFullYear() + "年" + mydate.getMonth() + "月" + mydate.getDay() + "日" + i[mydate.getDay()]+"<br />");
</script>
</head>
<body>
</body>
</html>
这两位同学的代码输出的日期显示都是4月2日,可是今天是17号,各位前辈请问代码哪出错了?