Javascript - Date Date Type

Introduction

ECMAScript Date type stores dates as the number of milliseconds that have passed since midnight on January 1, 1970 UTC (Universal Time Code).

Date type can accurately represent dates 285,616 years before or after January 1, 1970.

To create a date object, use the new operator along with the Date constructor, like this:

var now = new Date();

When the Date constructor is used without any arguments, the created object is assigned the current date and time.

To create a date based on another date or time, you must pass in the millisecond representation of the date.

Demo

var now = new Date();
console.log(now);

Result

Related Topics

Exercise