<html>
<head>
<title>显示当前日期和时间</title>
</head>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var now=new Date()
var year=now.getYear()
var month=now.getMonth()+1
var date=now.getDate()
var day=now.getDay()
document.write("<h2>当前日期:")
switch(now.getDay())
{
case 0:day="星期天" break
case 1:day="星期一" break
case 2:day="星期二" break
case 3:day="星期三" break
case 4:day="星期四" break
case 5:day="星期五" break
case 6:day="星期六" break
}
document.write(year+"年"+month+"月"+date+"日"+day+"<P>")
var hour=now.getHours()
var minute=now.getMinutes()
var second=now.getSeconds()
document.write("当前时间:")
document.write(hours+"时"+minute+"分"+second+"秒</h2>")
//-->
</SCRIPT>
</BODY>
</html>
<html>
<head>
<title>显示当前日期和时间</title>
</head>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var now=new Date()
var year=now.getYear()
var month=now.getMonth()+1
var date=now.getDate()
var day=now.getDay()
document.write("<h2>当前日期:")
switch(now.getDay())
{
case 0:day="星期天";break
case 1:day="星期一";break
case 2:day="星期二";break
case 3:day="星期三";break
case 4:day="星期四";break
case 5:day="星期五";break
case 6:day="星期六";break
}
document.write(year+"年"+month+"月"+date+"日"+day+"<P>")
var hour=now.getHours()
var minute=now.getMinutes()
var second=now.getSeconds()
document.write("当前时间:")
document.write(hour+"时"+minute+"分"+second+"秒</h2>")
//-->
</SCRIPT>
</BODY>
</html>
自己对照 哪儿错了
case 0:day="星期天" break
case 1:day="星期一" break
case 2:day="星期二" break
case 3:day="星期三" break
case 4:day="星期四" break
case 5:day="星期五" break
case 6:day="星期六" break
break前加分号
document.write(hours+"时"+minute+"分"+second+"秒</h2>")
hours改成hour
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息