Animations
API
Arrays
Async
Basics
Challenges
Classes
Console
Dates
Debugging
DOM Elements
DOM Methods
DOM Properties
Event Listeners
Flow Control
Forms
Functions
Global Functions
JSON
Keywords
Libraries (3rd party)
Math
Modules
Objects
Snippets
String
Types
Widgets
Window Object
There are generally 4 types of JavaScript date formats:
https://www.w3schools.com/js/js_dates.asp
Default Date Output
Independent of input format, JavaScript will (by default) output dates in full text string format.
let date1 = new Date();
document.getElementById("demo1").innerHTML = date1;
JavaScript ISO Dates
The ISO 8601 syntax (YYYY-MM-DD) is also the preferred JavaScript date format
(https://en.wikipedia.org/wiki/ISO_8601).
ISO 8601 is the international standard for the representation of dates and times.
The T in the date string, between the date and time, indicates UTC time: https://en.wikipedia.org/wiki/Coordinated_Universal_Time .
UTC (Universal Time Coordinated) is the same as GMT (Greenwich Mean Time).
let date2 = new Date("2017-04-30");
document.getElementById("demo2").innerHTML = date2;
let date3 = new Date("2017-04-30T12:30:00");
document.getElementById("demo3").innerHTML = date3;
JavaScript Short Dates
Short dates are most often written with an "MM/DD/YYYY" syntax like this:
let date4 = new Date("04/30/2017");
document.getElementById("demo4").innerHTML = date4;
JavaScript Long Dates
Long dates are most often written with a "MMM DD YYYY" syntax.
Months can be written in full like January, or abbreviated like Jan.
let date5 = new Date("Mar 25 2015");
document.getElementById("demo5").innerHTML = date5;