7 Replies Latest reply on Jul 25, 2009 2:39 PM by kglad

    display tomorrow's date problem . please help

    hrn023

      Hello, I have the following code. The idea is to display tomorrows date. I thought I had it working, but today it's showing undefined as the day. I would really appreciate some assistance to tweak it so it won't show undefined for any of the variables. Thanks in advance

      var currentDate=new Date();
      var weekDay=(currentDate.getDay() + 1);
      var weekDay_string:String;
      var month=currentDate.getMonth();
      var month_string:String;
      var numberDay=(currentDate.getDate() +  1);
      var numberDay_string:String;/* I use numberDay_string variable for adding a 0 before the days between 1 and 9. It's look better this way. */
      if (numberDay<10){
      numberDay_string="0"+numberDay;
      }else{
      numberDay_string=numberDay;
      }

      switch (month){
      case(0):month_string="January"; break;
      case(1):month_string="February"; break;
      case(2):month_string="March"; break;
      case(3):month_string="April"; break;
      case(4):month_string="May"; break;
      case(5):month_string="June"; break;
      case(6):month_string="July"; break;
      case(7):month_string="August"; break;
      case(8):month_string="September"; break;
      case(9):month_string="Octomber"; break;
      case(10):month_string="November"; break;
      case(11):month_string="December"; break;
      }

      switch (weekDay){
      case(0):weekDay_string="Sunday"; break;
      case(1):weekDay_string="Monday"; break;
      case(2):weekDay_string="Tuesday"; break;
      case(3):weekDay_string="Wednesday "; break;
      case(4):weekDay_string="Thursday"; break;
      case(5):weekDay_string="Friday "; break;
      case(6):weekDay_string="Saturday"; break;}

      displayDate_txt.text=weekDay_string+", "+month_string+" "+numberDay_string;