日期:2014-05-16  浏览次数:20425 次

求:为什么我写的代码 获取不到系统当前时间
<html>
<head>
<title> 獲取時間日期 </title> </head>
<body> <h2> 獲取時間日期 </h2>
<hr>
<script language="javascript">
var weekday = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var dttody=new date();
var output= dttody.getDate() + "/";
output+= (dttody.getMonth() + 1) + "/";
output+= dttody.getFullYear() + "<br>";
document.write("系統日期:" + output);

output=dttody.getHours() +":";
output+=dttody.getMinutes() +":";
output+=dttody.getSeconds() +"<br>";

document.write("系統時間:" +output);
document.write(weekday[dttoday.getDay()]);
</script>
</body>
</html>
 求指教啊,谢谢

------解决方案--------------------
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>獲取時間日期 </title>
</head>
<body>
    <h2>
        獲取時間日期
    </h2>
    <hr>
    <script language="javascript">
        var weekday = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
        var dttody = new Date();
        var output = dttody.getDate() + "/";
        output += (dttody.getMonth() + 1) + "/";
        output += dttody.getFullYear() + "<br>";
        document.write("系統日期:" + output);

        output = dttody.getHours() + ":";
        output += dttody.getMinutes() + ":";
        output += dttody.getSeconds() + "<br>";

        document.write("系統時間:" + output);
        document.write(weekday[dttody.getDay()]);
    </script>
</body>
</html>

------解决方案--------------------
探讨
var dttody = new Date(); date要大写

------解决方案--------------------
javascript中的内部代码构造函数都以大写开头的