-
Notifications
You must be signed in to change notification settings - Fork 0
/
date.html
32 lines (29 loc) · 1.13 KB
/
date.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
let now = Date.now();
let now1 = +new Date();
//上面两句代码效果相同
console.log(now) // 1552485937958 毫秒数 当前时间
console.log(now1)
let date=new Date();
console.log(date.getFullYear()); // 2019 年
console.log(date.getMonth()); // 2 月 (由于月的范围是 0-11 所以 2 其实是 3月)
console.log(date.getDate()); // 13 日
console.log(date.getDay()); // 3 星期3
console.log(date.getHours()) // 22 22点
console.log(date.getMinutes()) // 11 11分
console.log(date.getSeconds()) // 26 26秒
console.log(date.getMilliseconds()) // 390 390毫秒
let date1=new Date("2019-3-13 22:10:10");
console.log(+date1) // 1552486210000 2019/3/13 22:10:10
</script>
</body>
</html>