What Is the Date Object?

This article describes the different methods for obtaining dates in various formats. The Date object in JavaScript returns a number representing milliseconds since midnight on January 1, 1970. Time is presented in Coordinated Universal Time (UTC) and isn't converted to time zones. When using the getDay() function, it uses local time from the computer. However, when using getUTCDay(), it returns UTC day instead of local time. The Date object is very useful when we need a timestamp or something similar.

Static methods

Date.now()

Returns the numeric value corresponding to the current time-the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC, with leap seconds ignored.

Date.parse()

Parses a string representation of a date and returns the number of milliseconds since 1 January, 1970, 00:00:00 UTC, with leap seconds ignored.

Date.UTC()

Accepts the same parameters as the longest form of the constructor (i.e. 2 to 7) and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC, with leap seconds ignored.