JS调用时间
本帖最后由 良木 于 2020-9-12 18:11 编辑<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script type="text/javascript">
function ShowDate() {
var d = new Date();
var year = d.getFullYear();
var month = d.getMonth() + 1;
var day = d.getdate();
var week = d.getday();
if (week == 0) {
week = "日";
}
var hour = d.getHours();
var min = d.getMinutes();
var seconds = d.getSeconds();
return (
year +
"年" +
month +
"月" +
day +
"日 星期" +
week +
" " +
hour +
":" +
min +
":" +
seconds
);
}
alert(ShowDate());
</script>
</head>
<body></body>
</html>
代码如上 不知道哪里有错 又该怎么改 var year = d.getFullYear();
var month = d.getMonth() + 1;
var day = d.getDate();
var week = d.getDay();
要注意大小写
js里的方法大多为驼峰式getDay
而python则是下划线风格get_day
你写的是getday和getdate就会出错
要会看报错用编辑器也是可以避免的 试一下比如vscode
页:
[1]