June
27th,
2017
There are generally 4 types of JavaScript date input formats:
Type | Example |
---|---|
ISO Date | “2015-03-25” (The International Standard) |
Short Date | “03/25/2015” |
Long Date | “Mar 25 2015” or “25 Mar 2015” |
Full Date | “Wednesday March 25 2015” |
The ISO format follows a strict standard in JavaScript. The other formats are not so well defined and might be browser specific.
In some browsers, months or days with no leading zeroes may produce an error:
The behavior of “YYYY/MM/DD” or “DD-MM-YYYY” is undefined. Some browsers will try to guess the format. Some will return NaN.
Independent of input format, JavaScript will (by default) output dates in full text string format: