Date getDay() Method - Javascript Date

Javascript examples for Date:getDay


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.



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>

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

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

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


Related Tutorials