1var today = new Date();
2var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
3var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
4var dateTime = date+' '+time;
5
1var today = new Date();
2var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
3
1var today = new Date();
2 var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
3 console.log(date)
4// output 2021-7-9
1const localDate = new Date();
2const months = [
3 "January",
4 "February",
5 "March",
6 "April",
7 "May",
8 "June",
9 "July",
10 "August",
11 "September",
12 "October",
13 "November",
14 "December",
15];
16
17const days = [
18 "Sunday",
19 "Monday ",
20 "Tuesday",
21 "Wednesday",
22 "Thursday",
23 "Friday",
24 "Saturday",
25];
26const currentDay = days[localDate.getDay()];
27
28const currentDate = localDate.getDate();
29
30const currentMonth = months[localDate.getMonth()];
31
32const currentYear = localDate.getFullYear();
33
34console.log(`${currentDay}, ${currentDate} ${currentMonth}, ${currentYear}`);
1var today = new Date();
2var dd = today.getDate();
3
4var mm = today.getMonth()+1;
5var yyyy = today.getFullYear();
6
7dd = dd < 10 ? '0'+ dd : dd;
8mm = mm < 10 ? '0'+ mm : mm;
9
10today = mm+'-'+dd+'-'+yyyy;
11console.log(today);
12