Date & Time in JavaScript

Date & Time in JavaScript

ยท

1 min read

Date objects are created with the new Date() constructor.

JavaScript new Date(): new Date() creates a date object with the current date and time:

new Date(year, month, ): creates a date object with a specified date and time.

There are many ways to create a new date object:

new Date()

new Date(date string)

new Date(year,month)

new Date(year,month,day)

new Date(year,month,day,hours)

new Date(year,month,day,hours,minutes)

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

new Date(year,month,day,hours,minutes,seconds,ms)

new Date(milliseconds)

ย