Date.getUTCDay() : getUTCDay « Date « JavaScript Tutorial






The getUTCDay() method returns the day of the week converted to universal time and expressed as an integer from 0 (Sunday) to 6 (Saturday).

The following example uses the getUTCDay() Method to Return the Day of the Week

<html>
    <script language="JavaScript">
    <!--
    function getDayString(num)
    {
      var day;    //Create a local variable to hold the string
      switch(num)
      {
        case 0:
          day="Sunday";
          break;
        case 1:
          day="Monday";
          break;
        case 2:
          day="Tuesday";
          break;
        case 3:
          day="Wednesday";
          break;
        case 4:
          day="Thursday";
          break;
        case 5:
          day="Friday";
          break;
        case 6:
          day="Saturday";
          break;
        default:
          day="Invalid day";
      }
      return day;
    }
    theDate = new Date();
    document.write("The UTC day is ",getDayString(theDate.getUTCDay()));
    -->
    </script>
    </html>








12.16.getUTCDay
12.16.1.Date.getUTCDay()