Date getDay() Method - Javascript Date

Javascript examples for Date:getDay

Description

The getDay() method returns the day of the week (from 0 to 6) for the specified date.

Sunday is 0, Monday is 1, and so on.

Parameters

None

Return Value:

A Number, from 0 to 6, representing the day of the week

The following code shows how to return the day of the week:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from w  ww. ja  v  a  2s .  c om*/
    var d = new Date();
    var n = d.getDay()
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

Related Tutorials