Sponsors

Web Designer? Design and market your own professional website with easy-to-use tools.

Compare, review and buy thousands of Laptops , software products at CheckCost.co.uk

Your Text Link Here! and your text description here!

Javascript getDay() Method

The javascript getDay() method returns a number that represents the day of the week.

The value that is returned by the getDay() method is a number between 0 and 6, for example, if you assing Sunday the number 0, then Monday will be 1, Tuesday will be 2 and so on. The getDay() method is always used in conjunction with a Date object.

The syntax for the using the getDate() method is:

dateObject.getDay()

The javascript below outputs the current day of the week.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>WebDevelopmentTutorials.com</title>
</head>
<body>

<script type="text/javascript" language="javascript">

var day = new Date();

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

document.write("Today it is " + weekday[day.getDay()]);

</script>

</body>
</html>

The javascript above outputs:

Free Website Hosting

WebDevelopmentTutorials.com