setFullYear()

The setFullYear() method is used to set the current year of the Date object to the four digit year 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.setFullYear(four digit year)

EXAMPLE

dateObject = new Date();

dateObject.setFullYear(1999);

document.write("The date is: " + dateObject.getFullYear());

The example shows the creation of a new Date object, called dateObject. The setFullYear() method is then set to 1999. Then a document.write statement is declared with the getFullYear() method to display the new value of the dateObject after the string of text..