Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JS Dates Formats

JavaScript Date Input

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.

JavaScript Date Output

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)

JavaScript ISO Dates

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.

Example (Complete date)

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.