javascript get current day code example
Example 1: javascript get time
var time = new Date();
time.getDate();
time.getDay();
time.getFullYear();
time.getHours();
time.getMinutes();
time.getSeconds();
time.getMilliseconds();
time.getTime();
time.toDateString();
time.toLocaleString();
time.toLocaleTimeString();
time.toLocaleDateString();
Example 2: javascript get current time
var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
Example 3: get date javascript
var d= new Date();
d.getFullYear();
d.getMonth();
d.getDate();
d.getHours();
d.getMinutes();
d.getSeconds();
d.getMilliseconds();
d.getTime();
Example 4: get day js
switch (new Date().getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
}
Example 5: javascript date get current date
var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var dateTime = date+' '+time;
The dateTime variable contains result as:
2018-8-3
Example 6: javascript get current day of month
new Date().getDate();