This method is used to set the full year for the supplied date according to universal time.
This method is used to set the full year for the supplied date according to universal time. If you do not supply the monthVal and dayVal arguments, JavaScript will use the values returned using the getMonth and getDay methods. Also, if the supplied argument is outside the range expected, the setUTCFullYear method will alter the other parameters accordingly (see example below).
myDate = new Date()
document.write(myDate +"<br>")
myDate.setUTCFullYear(1999, 08, 35)
document.write(myDate)
Fri Jul 9 12:32:32 UTC+0100 1999
Sat Sep 4 12:32:32 UTC+0100 1999
This example uses the setUTCFullYear method to change the value of the myDate object and also demonstrates how this method will adjust the other parameters if a value is supplied that exceeds the expected range. In this case the dayVal supplied is 35 which causes the monthVal value to be incremented by 2.
This is calculated thus:
35 - 31(maximum expected value for month) = 4 (this increments monthVal by one).
The result is that setUTCFullYear method uses 4 for for the dayVal
and increments the monthVal by one, from 8 to 9.