So without further ado, let’s begin.
This method returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
But why January 1, 1970? Because it is known as UNIX epoch or “epoch date” is the date when the time started for Unix computers. This is marked as 0. Any time since that date is calculated based on the number of seconds elapsed.
const time = new Date().getTime();//1598.........
Get Full Year
To get the year as a four digit number (yyyy)
const year = new Date().getFullYear();//2020
This method is used to get month as a number (0–11) so to get the correct month you need to add 1.
const month = new Date().getMonth() + 1;//8
const day = new Date().getDay();//1 if it is Monday today
Get the hour as a number (0–23)
const hour = new Date().getHours();//10
To get the minutes as number (0–59)
const minutes = new Date().getMinutes();//30
Get the date as a number (1–31)
const date = new Date().getDate();//3