Date
There are 9 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)
Example:
let now = new Date()
console.log(now.getTime())
console.log(now.getFullYear())
console.log(now.getMonth()) //starts from 0
console.log(now.getDate())
console.log(now.getDay())
console.log(now.getHours())
console.log(now)
console.log(now.toString())
Expected Output :-
1678219087040
2023
2
7
2
19
2023-03-07T19:58:07.040Z
Tue Mar 07 2023 19:58:07 GMT+0000 (Coordinated Universal Time)