setUTCFullYear()
Date
instance method setterS2C Home
« Globals « Date « setUTCFullYear()
Description
Sets the UTC year (CCYY) for the specified date.
Syntax
Signature | Description |
---|---|
aDate.setUTCFullYear( yearInt[, monthInt[, dayInt]]) | Sets the UTC year (CCYY) for the specified date. |
Parameters
Parameter | Description |
---|---|
yearInt | An integer specifying the year. |
monthInt | An integer in the range 0-11. January=0, February=1 etc.
|
dayInt | An integer in the range 1-31.
|
For specified values outside the ranges above the setUTCFullYear() method will try and set the date accordingly. |
Examples
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();
alert(todaysDate);
// Set Year.
todaysDate.setUTCFullYear(2005);
alert(todaysDate + ' - UTC Year set to 2005');
// Set all parameters.
todaysDate.setUTCFullYear(2001,1,1);
alert(todaysDate + ' - UTC Year all parameters set');
Related Tutorials
JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times