| setMonths() The setMonths() method is used to set the number of months within the date object. The value of the Date object is between 0 and 11, and specified within brackets, which may be referred to as the condition or argument of the method. The date object will then use this value for its operations. The date and time of your system clock is not consulted with this method. syntax: dateObjectName.setMonths(month) EXAMPLE dateObject = new Date(); dateObject.setMonths(11); document.write("The date is: " + dateObject.getMonths()); The example shows the creation of a new Date object, called dateObject. The setMonth() method is then set to 11. Then a document.write statement is declared with the getMonths() method to display the new value of the dateObject after the string of text.. |