JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow Date Right Arrow setUTCFullYear()

setUTCFullYear()  Date  instance method


Sets the UTC year (CCYY) for the specified date.


Signature Description
aDate.setUTCFullYear( yearInt[, monthInt[, dayInt]])Sets the UTC year (CCYY) for the specified date.


Parameter Description
yearIntAn integer specifying the year.
monthIntAn integer in the range 0-11. January=0, February=1 etc.
  • If monthInt is not specified the value returned from the getUTCMonth() method is used.
dayIntAn integer in the range 1-31.
  • If dayInt is not specified the value returned from the getUTCDate() method is used.
  • If dayInt is specified you must also specify monthInt.

For specified values outside the ranges above the setUTCFullYear() method will try and set the date accordingly.


The code below displays shows examples of the setUTCFullYear() method of Date.

// Create a Date instance for the current date and time.
var todaysDate = new Date();
// Set Year.
alert(todaysDate + ' - UTC Year set to 2005');
// Set all parameters.
alert(todaysDate + ' - UTC Year all parameters set');

Press the button below to action the above code:

Related Tutorials

JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times


go to home page Homepage go to top of page Top