Home
<!DOCTYPE html> <html> <body> <h1>Demo: JavaScript Date Object</h1> <p id="p1"></p> <p id="p2"></p> <p id="p3"></p> <p id="p4"></p> <p id="p5"></p> <script> var date1 = new Date(2021, 2, 3); // Mon Feb 03 2021 var date2 = new Date(2021, 2, 3, 10); // Mon Feb 03 2021 10:00 var date3 = new Date(2021, 2, 3, 10, 30); // Mon Feb 03 2021 10:30 var date4 = new Date(2021, 2, 3, 10, 30, 50); // Mon Feb 03 2021 10:30:50 var date5 = new Date(2021, 2, 3, 10, 30, 50, 800); // Mon Feb 03 2021 10:30:50 document.getElementById("p1").textContent = date1; document.getElementById("p2").textContent = date2; document.getElementById("p3").textContent = date3; document.getElementById("p4").textContent = date4; document.getElementById("p5").textContent = date5; </script> </body> </html>
Result: