Translate the Date().getDay() to a string day name : getDay « Date « JavaScript Tutorial






The getDay() method returns the day of the week expressed as an integer from 0 (Sunday) to 6 (Saturday).

The following example uses the getDate() Method to Return the Day of the Week

<html>
<head>
<title>Convert Day of the Week</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--

var weekdays = new Array(7);
weekdays[0] = "Sunday";
weekdays[1] = "Monday";
weekdays[2] = "Tuesday";
weekdays[3] = "Wednesday";
weekdays[4] = "Thursday";
weekdays[5] = "Friday";
weekdays[6] = "Saturday";

var current_date = new Date();

weekday_value = current_date.getDay();

document.write("Today is " + weekdays[weekday_value]);

//-->
</script>
</body>
</html>








12.6.getDay
12.6.1.Get day from a date
12.6.2.Translate the Date().getDay() to a string day name
12.6.3.Date.getDay() with switch statement