Introduction to js date format
Javascript date format is a platform-independent format representing one and a single moment in time. It’s an intregal number representing milliseconds since January 1, 1970, UTC (the epoch) midnight at the beginning.
What are constructors in js date format?
- Date(): Current date and time representing a string are returned when using date() constructors.
- New date(): A new date object is returned using this constructor.
Types of JavaScript date formats
- ISO Dates : “2023-01-17”(international standard)
- Short Date: “7-15-2020”
- Long Date: “Jan 17 2023” or “17 Jan 2023”
ISO format in JavaScript follows a strict standard. Two other formats are not defined well and they might be browser specific.
Output of JavaScript Date format
The default output dates for js date format, independent of the platform, is in full string format.
Mon Jan 16 2023 12:47:13 GMT+0530 (India Standard Time)
ISO DATES –
The international standard for dates and times is Iso 806 whose syntax (YYYY-MM-DD) is the preferred format for javascript date. js date format yyyy-mm-dd is standard format.
Syntax for Iso Date
const date = new Date(“2023-01-17”);