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> <p id="p6"></p> <p id="p7"></p> <p id="p8"></p> <p id="p9"></p> <script> var date1 = new Date("3 march 2015"); var date2 = new Date("3 February, 2015"); var date3 = new Date("3rd February, 2015"); // invalid date var date4 = new Date("2015 3 February"); var date5 = new Date("3 2015 February "); var date6 = new Date("February 3 2015"); var date7 = new Date("February 2015 3"); var date8 = new Date("3 2 2015"); var date9 = new Date("3 march 2015 20:21:44"); document.getElementById("p1").innerHTML = date1; document.getElementById("p2").innerHTML = date2; document.getElementById("p3").innerHTML = date3; document.getElementById("p4").innerHTML = date4; document.getElementById("p5").innerHTML = date5; document.getElementById("p6").innerHTML = date6; document.getElementById("p7").innerHTML = date7; document.getElementById("p8").innerHTML = date8; document.getElementById("p9").innerHTML = date9; </script> </body> </html>
Result: