1var d= new Date();
2d.getFullYear(); //Get the year as a four digit number (yyyy)
3d.getMonth(); //Get the month as a number (0-11)
4d.getDate(); //Get the day as a number (1-31)
5d.getHours(); //Get the hour (0-23)
6d.getMinutes(); //Get the minute (0-59)
7d.getSeconds(); //Get the second (0-59)
8d.getMilliseconds() //Get the millisecond (0-999)
9d.getTime(); //Get the time (milliseconds since January 1, 1970)
10d.getDay(); //Get the weekday as a number (0-6)
11d.Date.now(); //Get the time. ECMAScript 5.
12d.setDate() //Set the day as a number (1-31)
13d.setFullYear() //Set the year (optionally month and day)
14d.setHours() //Set the hour (0-23)
15d.setMilliseconds() //Set the milliseconds (0-999)
16d.setMinutes() //Set the minutes (0-59)
17d.setMonth() //Set the month (0-11)
18d.setSeconds() //Set the seconds (0-59)
19d.setTime() //Set the time (milliseconds since January 1, 1970)
1var currentDate = new Date();
2
3var date = currentDate.getDate();
4var month = currentDate.getMonth(); //Be careful! January is 0 not 1
5var year = currentDate.getFullYear();
6
7var dateString = date + "-" +(month + 1) + "-" + year;
8
1let dateStr =new Date("Wed Aug 05 18:11:48 UTC 2020")
2
3dateStr.toLocaleDateString()
4// "05/08/2020"
5
6dateStr.toTimeString()
7// "23:41:48 GMT+0530 (India Standard Time)"
8