JavaScript Date รองรับรูปแบบดังนี้
| Date Type | Format |
|---|---|
| ISO Date | "2017-11-29" (International Standard) |
| Short Date | "11/29/2017" |
| Long Date | "29 Nov 2017" |
| Full Date | "Wednesday November 29 2017" |
ตัวอย่างแสดงวันที่ปัจจุบัน
<!DOCTYPE html> <html>
<body>
<p>คลิกเพื่อดูวันที่ปัจจุบัน:</p>
<button onclick="display()">Display Date</button>
<p id="test"></p>
<script>
function display() {
var date = new Date();
document.getElementById("test").innerHTML = date;
}
</script>
</body>
</html>