setUTCMonth()
Date
instance method
JS Home <<
JS Reference <<
Date <<
setUTCMonth()
Description
Sets the UTC month of the year (0-11) for the specified date.
Syntax
Signature | Description |
---|---|
aDate.setUTCMonth(monthInt[, dayInt]) | Sets the UTC month of the year (0-11) for the specified date. |
Parameters
Parameter | Description |
---|---|
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 setUTCMonth() method will try and set the date accordingly. |
Examples
The code below shows examples of the setUTCMonth()
method of Date
.
// Create a Date instance for the current date and time.
var todaysDate = new Date();
alert(todaysDate);
// Set UTC month.
todaysDate.setUTCMonth(3);
alert(todaysDate + ' UTC Month set to 3');
// Set UTC month and day.
todaysDate.setUTCMonth(7,7);
alert(todaysDate + ' UTC Month and day set');
Related Tutorials
JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times