Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Đối tượng Date trong JavaScript là gì?

Date là kiểu dữ liệu dựng sẵn trong JavaScript. Tạo đối tượng Date bằng các cách:

new Date()
new Date(milliseconds)
new Date(dateString)
new Date(year, month, day[, hour, minute, second, millisecond])

Ví dụ

<html>
  <head>
    <title>Đối tượng Date trong JavaScript</title>
  </head>
  <body>
    <script>
      var date = new Date();
      document.write("Constructor: " + date.constructor);
    </script>
  </body>
</html>

Kết quả

Constructor: function Date() { [native code] }