5.Date对象.html 785 B

12345678910111213141516171819202122232425
  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.getDate()); //getDate 日期
  12. console.log(date.getDay()); //getDay 星期
  13. console.log(date.getFullYear()); //getFullYear 年
  14. console.log(date.getMonth() + 1); //getMonth 月 0-11
  15. console.log(date.getHours()); //getHours 小时
  16. console.log(date.getMinutes()); //getMinutes 分钟
  17. console.log(date.getSeconds()); //getSeconds 秒
  18. console.log(date.getTime()); //getTime 当前时间时间戳
  19. console.log(date.getMilliseconds()) //getMilliseconds 当前毫秒
  20. </script>
  21. </body>
  22. </html>