Date.setUTCFullYear() (Method)

Sets the UTC full year value of the time object.

Availability:

ECMAScript edition - 2
JavaScript - 1.3
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.0
Property/method value type:Time value
JavaScript syntax:-myDate.setUTCFullYear(aYearValue)
-myDate.setUTCFullYear(aYearValue, aMonthValue)
-myDate.setUTCFullYear(aYearValue, aMonthValue, aDateValue)
Argument list:aDateValueAn optional date within the month value
aMonthValueAn optional 0 to 11 month value
aYearValueA full year value

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

The computations are carried out in UTC time coordinates.

ECMA mandates that the month and date should be optional arguments. If the date value is omitted, the value is provided internally as if the getUTCDate() method had been called to provide it. Likewise the month value will be replaced by internally calling the getUTCMonth() method.

Example code:

   <HTML>

   <HEAD>

   </HEAD>

   <BODY>

   <SCRIPT>

   myArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

   myDate = new Date();

   myDate.setUTCFullYear(myDate.getFullYear() - 1);

   document.write("A year ago on today's date, it was a " + myArray[myDate.getDay()]);

   </SCRIPT>

   </BODY>

   </HTML>

See also:Date.getFullYear(), Date.getUTCFullYear(), Date.prototype, Date.setFullYear()

Cross-references:

ECMA 262 edition 2 - section - 15.9.5.37

ECMA 262 edition 3 - section - 15.9.5.41