17.Date对象.html 784 B

12345678910111213141516171819202122
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. var date = new Date();
  11. console.log(date.getFullYear(),'当前年份');
  12. console.log(date.getMonth() + 1,'当前月份');//取值范围0~1
  13. console.log(date.getDate(),'当前日期');
  14. console.log(date.getHours(),'当前小时');
  15. console.log(date.getMinutes(),'当前分钟');
  16. console.log(date.getSeconds(),'当前秒数');
  17. console.log(date.getMilliseconds(),'当前毫秒');
  18. console.log(date.getDay(),'当前星期');
  19. console.log(date.getTime(),'获取当前时间的时间戳');
  20. </script>
  21. </body>
  22. </html>