Date.setMonth() (Method)

Sets the month number of the time object.


ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Time value
JavaScript syntax:-myDate.setMonth(aMonthValue)
- (JavaScript 1.3 +)myDate.setMonth(aMonthValue, aDateValue)
Argument list:aDateValueAn optional value in days of the month
aMonthValueA value between 0 and 11 in months

The result returned by this method will be the new time value of the containing object having been adjusted by the values passed in as arguments.

The computations are carried out in local time coordinates.

ECMA mandates that the date should be an optional argument. If the date value is omitted, the value is provided internally as if the getDate() method had been called to provide it.

Example code:

   myArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
   myDate  = new Date();
   document.write("The fourth of July this year is a " + myArray[myDate.getDay()]);

See also:Date.getMonth(), Date.prototype, Date.setUTCMonth()


ECMA 262 edition 2 - section -

ECMA 262 edition 3 - section -