Sets the month of the date

Description

setMonth(month)
Sets the month of the date, which is any number 0 or greater. Numbers greater than 11 add years.

Example


      var myDate = new Date();
      /*from   w ww. j  a v  a 2s.c  o  m*/
      myDate.setMonth(2);
      console.log(myDate.toString());
      

The code above generates the following result.





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window