JavaScript Date Formats JAVASCRIPT
- JavaScript Introduction
- JavaScript Syntax
- JavaScript innerHTML
- JavaScript document.write()
- Javascript - window.alert()
- JavaScript - console.log()
- JavaScript Comments
- JavaScript Variables
- JavaScript Operators
- JavaScript Data Types
- JavaScript Functions
- JavaScript Objects
- JavaScript Events
- JavaScript Strings
- JavaScript String Methods
- JavaScript Numbers
- JavaScript Number Methods
- JavaScript Arrays
- JavaScript Array Methods
- JavaScript Sorting Arrays
- JavaScript Array Iteration
- JavaScript Date Objects
- JavaScript Date Formats
- JavaScript Get Date Methods
- JavaScript Set Date Methods
- JavaScript Math Object
- JavaScript Conditions
- JavaScript Switch
- JavaScript Loop For
- JavaScript While Loop
- JavaScript Break and Continue
- JavaScript Type Conversion
- JavaScript Errors
- JavaScript Scope
- JavaScript this Keyword
- JavaScript Classes
- JavaScript Debugging
- JavaScript - Changing CSS
- JavaScript JSON
JavaScript Date Formats
JavaScript Date Input
There are generally 3 types of JavaScript date input formats:
Type | Example |
---|---|
ISO Date | "2020-01-25" (The International Standard) |
Short Date | "01/25/2020" |
Long Date | "Jan 25 2020" or "25 Jan 2020" |
The ISO format follows a strict standard in JavaScript.
The other formats are not so well defined and might be browser-specific.
JavaScript Date Output
Independent of input format, JavaScript will (by default) output dates in full-text string format:
Wed Jan 25 2020 05:30:00 GMT+0530 (India Standard Time)
JavaScript ISO Dates
ISO 8601 is the international standard for the representation of dates and times.
The ISO 8601 syntax (YYYY-MM-DD) is also the preferred JavaScript date format:
Example (Complete date)
JavaScript Long Dates.
Long dates are most often written with a "MMM DD YYYY" syntax like this:
JavaScript Short Dates
Short dates are written with an "MM/DD/YYYY" syntax like this:
ISO Dates (Date-Time)
ISO dates can be written with added hours, minutes, and seconds (YYYY-MM-DDTHH:MM:SSZ):
The date and time are separated with a capital T.
UTC time is defined with a capital letter Z.
If you want to modify the time relative to UTC, remove the Z and add +HH:MM or -HH:MM instead: