Đối tượng Date là một kiểu dữ liệu được tích hợp trong ngôn ngữ JavaScript. Đối tượng ngày được tạo bằng Date () mới như hình bên dưới -
new Date( ) new Date(milliseconds) new Date(datestring) new Date(year,month,date[,hour,minute,second,millisecond ])
Ví dụ
Bạn có thể thử chạy mã sau để triển khai đối tượng Ngày trong JavaScript -
<html>
<head>
<title>JavaScript Dates</title>
</head>
<body>
<script>
var date = new Date();
document.write("dt.constructor is : " + date.constructor);
</script>
</body>
</html> Đầu ra
dt.constructor is : function Date() { [native code] }