get day js
snippet in javascript

get day js

user8631

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";
}

javascript get day

user2128


var d = new Date();

var days = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"];

document.getElementById("demo").innerHTML = days[d.getDay()];
// get the name of the week as string and not number
 

new date getday js

user734

Date.getDay()
// Javascript date getDay() method returns the day of the week for the specified
// date according to local time. The value returned by getDay() is an integer 
// corresponding to the day of the week: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on.