JavaScript setUTCFullYear method

setUTCFullYear() method sets the full year for the provided date according to the Universal Coordinated Time (UTC).

JavaScript setUTCFullYear method

setUTCFullYear() method sets the full year for the provided date
according to the Universal Coordinated Time (UTC). Following is the syntax for
using setUTCFullYear() is as follows :

Syntax :

date_object.setUTCFullYear( year, month, day );

Where year is required parameter and month and day are optional. If we want
to set only year then we can pass only one parameter year within method setUTCFullYear().

Description of example code:

To illustrate the use of setUTCFullYear() method we have created a
simple HTML page into which we have three input text boxes to take three
input values year , month and day. We also have created a button "Set
UTC date" which calls the function setUTCFullYearFunc() on the
button click. Code for function is as follows :

In the above lines of code, first three lines of code specifies that we have
taken the year, month and day values into three variables
and then further these would be passed to the setUTCFullYear() method to
set UTC( Universal Coordinated Time ) date. Here is the full code in HTML as follows :