2 Replies Latest reply on Sep 7, 2011 11:08 PM by JabbyPandaUA

    Substracting 1 month from existing date

    JabbyPandaUA Level 3

      Hi all,

       

      var startDate : Date = new Date (2011, 7, 1, 0, 30);
      var newDate : Date = new Date (startDate.time); 
      trace ("startDate=", startDate);//displays locally Mon Aug 1 00:30:00 GMT+0200 2011
      newDate.monthUTC -= 1;
      trace ("newDate=", newDate); //Mon Jul 2 00:30:00 GMT+0200 2011
      
      

       

       

      Why newDate is 2 July, not 1 July ?

       

      When I change the line newDate.monthUTC -= 1 to newDate.setUTCMonth(6), the new Date will be 1 July, 2011.