On this page

Date class in JavaScript

Enrico Hochkoeppler Profile

By Enrico Hochkoeppler

Web Developer & TutoriaLibre Founder

Date instantiation and properties​

A date consists of a year, a month, a day, an hour, a minute, a second and milliseconds.

Initiating a new Date object with no arguments creates a date instance with the current date and time. You can pass arguments to create a specified date.


new Date(milliseconds);

new Date(dateString);

new Date(year, month, day, hours, minutes, seconds, milliseconds);

Dates in JavaScript are created in milliseconds starting from 1 January 1970 at 00:00:00 UTC

1 day = 86,400,000 milliseconds

Months start from January and are counted from 0

Date methods​

Method****DescriptiongetFullYear()gets the yeargetMonth()gets the monthgetDate()gets the date of the monthgetDay()gets the day of the weekgetHours()getMinutes()getSeconds()getMilliseconds()

Found this helpful? Share the knowledge...

... or support this project to keep it alive!

Buy Me a Coffee

Previous

Math

Next

Maps