get day in js code example
Example 1: 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 2: javascript get day
var d = new Date();
var n = d.toLocaleString("en-US", { "weekday": "long" });
n += "\n" + d.toLocaleString("en-US", { "weekday": "short" });
n += "\n" + d.toLocaleString("en-US", { "weekday": "narrow" });
Example 3: javascript get day
var d = new Date();
var n = d.getDay();