Working With the Date Type

In this lesson, we'll cover the date type in JavaScript. Let's begin!

We'll cover the following...

JavaScript specifies Boolean, Number, and String as primitive value types. Interestingly, it does not use a primitive value type for handling date and time values.

Instead,


The standard defines the date type (reference type) that stores dates as the number of milliseconds that have passed since midnight on January 1, 1970 UTC (Universal Time Code).


Leveraging this data storage format, the Date type can accurately represent dates almost 300,000 years before or after January 1, 1970.

Creating a date variable

To create a date, use the Date() constructor function, and pass the number representation as an argument. When the argument is omitted, the new object is assigned the current ...