1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <title>Title</title>
6
7 </head>
8 <body>
9 <div id="tab">
10 <input type="text" id="inputdate">
11
12 </div>
13
14 <script>
15 window.onload = function () {
16 /*
17 * 主要是把 把 Tue Dec 24 2019 12:02:03 时间格式 截取出年份
18 * */
19 var standardDate = new Date('2018,9,1');
20 var year = JSON.stringify(standardDate);
21 console.log(year.slice(1,5))
22 var year1 = JSON.stringify(standardDate.getFullYear());
23 console.log(year1)
24
25
26 };
27
28
29
30 </script>
31 </body>
32 </html>