Translate the Date().getDay() to a string day name : getDay : Date JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Date » getDay »

 

Translate the Date().getDay() to a string day name








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>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Date
» getDay