Date getUTCDay() Method - Javascript Date

Javascript examples for Date:getUTCDay

Description

The getUTCDay() method returns the day of the week (from 0 to 6) for the specified date, according to universal time.

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

UTC time is the same as GMT time.

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, according to universal time:

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  w  w.  ja  va  2s  .  c  o m*/
    var d = new Date();
    var n = d.getUTCDay();
    document.getElementById("demo").innerHTML = n;
}
</script>

<p><strong>Note:</strong> 0=Sunday, 1=Monday, etc.</p>

</body>
</html>

Related Tutorials