| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- // 时间对象 new Date();
- // 时间对象可以用来表示时间
- var date = new Date();
- // 获取时间对象的年
- console.log(date.getFullYear());
- // 获取时间对象的月 月份从0开始
- console.log((date.getMonth()+1));
- // 获取时间对象的天
- console.log(date.getDate());
- // 获取时间对象的小时
- console.log(date.getHours());
- // 获取时间对象的分钟
- console.log(date.getMinutes());
- // 获取时间对象的秒
- console.log(date.getSeconds());
- // 获取星期 星期天为 0, 星期一为 1, 以此类推
- console.log(date.getDay());
-
- // Number对象
- var a = 10;
- console.log(a.toString());
- </script>
- </body>
- </html>
|