Date.getDay() with switch statement : getDay : Date JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Date » getDay »

 

Date.getDay() with switch statement

















<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("Today is ",getDayString(theDate.getDay()));

    -->
    </script>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Date
» getDay