Date getUTCDay() Method - Javascript Date

Javascript examples for Date:getUTCDay


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.



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>

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

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

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;

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


Related Tutorials