Availability: |
| ||||||||
Property/method value type: | Time value | ||||||||
JavaScript syntax: | - | myDate.setMonth(aMonthValue) | |||||||
- (JavaScript 1.3 +) | myDate.setMonth(aMonthValue, aDateValue) | ||||||||
Argument list: | aDateValue | An optional value in days of the month | |||||||
aMonthValue | A 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.
<HTML> <HEAD></HEAD> <BODY> <SCRIPT> myArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); myDate = new Date(); myDate.setDate(4); myDate.setMonth(6); document.write("The fourth of July this year is a " + myArray[myDate.getDay()]); </SCRIPT> </BODY> </HTML>
See also: | Date.getMonth(), Date.prototype, Date.setUTCMonth() |
Prev | Home | Next |
Date.setMinutes() | Up | Date.setSeconds() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |