ออบเจกต์ Date เป็นชนิดข้อมูล (datatype) ที่สร้างอยู่ในภาษา JavaScript ไว้แล้ว ออบเจกต์ Date ถูกสร้างด้วย new Date() ดังตัวอย่างด้านล่าง:
new Date() new Date(milliseconds) new Date(datestring) new Date(year, month, date[, hour, minute, second, millisecond])
ตัวอย่าง
ลองรันโค้ดด้านล่างเพื่อใช้งานออบเจกต์ Date ใน JavaScript
<html>
<head>
<title>JavaScript Dates</title>
</head>
<body>
<script>
var date = new Date();
document.write("dt.constructor is : " + date.constructor);
</script>
</body>
</html>
ผลลัพธ์
dt.constructor is : function Date() { [native code] }