JavaScript Long Dates

Long dates are most often written with a "MMM DD YYYY" syntax like this:

   var d = new Date("Mar 25 2015");

HTML file: Displayed by browser:
<body>
<h4>Example of a long date:</h4>
<p id="demo"></p>
<script>
var d = new Date("Mar 25 2015");
document.getElementById("demo").innerHTML = d;
</script>
</body>

Example of a long date:

The year, month, and day can be in any order. The month can be written in full (January), or abbreviated (Jan). Commas are ignored. Names are not case sensitive, so you can use all-caps or lower case. All of the following declarations will return the same date format as shown in the HTML/Browser example above:

   variable = new Date("25 Mar 2015");
   variable = new Date("2015 Mar 25");
   variable = new Date("January 25 2015");
   variable = new Date("Jan 25 2015");
   variable = new Date("2015, JANUARY, 25");

BackTable of ContentsNext