1// these are the most useful ones IMO
2var time = new Date();
3time.getDate(); // returns value 1-31 for day of the month
4time.getDay(); //returns value 0-6 for day of the week
5time.getFullYear(); //returns a 4 digit value for the current year
6time.getHours(); //returns value 0-23 for the current hour
7time.getMinutes(); //returns value 0-59 for the current minute of the hour
8time.getSeconds(); //returns value 0-59 for current second of the minute
9time.getMilliseconds(); //returns value 0-999 for current ms of the second
10time.getTime(); //returns date as ms since Jan 1, 1970
11time.toDateString(); //returns a string (e.g. "Fri May 9 2020")
12time.toLocaleString(); //returns date and time (e.g. "9/12/2015, 6:08:25 PM")
13time.toLocaleTimeString(); //returns time (e.g. "6:08:25 PM")
14time.toLocaleDateString(); //returns date (e.g. "9/12/2015")
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 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)
1const handleTime = (dataD) => {
2 let data= new Date(dataD)
3 let hrs = data.getHours()
4 let mins = data.getMinutes()
5 if(hrs<=9)
6 hrs = '0' + hrs
7 if(mins<10)
8 mins = '0' + mins
9 const postTime= hrs + ':' + mins
10 return postTime
11 }
1var currentDate = new Date();
2var dateFromTimeStamp= new Date(1560807962);
3var dateFromString = new Date('December 17, 1995 03:24:00');
4//new Date(year, month, day, hours, minutes, seconds, milliseconds)
5//0= Jan, 11=Dec
6var dateFromYearMonthDay = new Date(2018, 11, 26, 0, 0, 0, 0);