JavaScript date input formats can generally be categorized into three types:
Type |
Example |
ISO Date |
“2015-03-25” (The International Standard) |
Short Date |
“03/25/2015” |
Long Date |
“Mar 25 2015” or “25 Mar 2015” |
The ISO format adheres to a strict standard in JavaScript, while other formats may vary and could be browser-specific. |
Regardless of the input format, JavaScript will typically output dates in full text string format by default.
Sat Apr 27 2024 19:22:42 GMT+1000 (Australian Eastern Standard Time) |
ISO 8601 serves as the international standard for representing dates and times.
The YYYY-MM-DD syntax, part of ISO 8601, is the recommended date format in JavaScript.
const d = new Date(“2015-03-25”); |
The resulting computed date will vary based on your time zone. Consequently, the output may range between March 24 and March 25, depending on your local time zone. |