JavaScript by Example: Dates & Times

Creating a new date object in JavaScript is done by creating a new instance of "Date".

Note that JavaScript counts months from 0 to 11 where January is 0 and December is 11.

All dates are stored as milliseconds since January 1st, 1970.

// year, month, day, hours, minutes, seconds, milliseconds
const date = new Date(2018, 11, 24, 10, 33, 30, 0);