setUTCMonth()  Date  instance method JS Home  <<  JS Reference  <<  Date  <<  setUTCMonth()


Sets the UTC month of the year (0-11) for the specified date.


Signature Description
aDate.setUTCMonth(monthInt[, dayInt])Sets the UTC month of the year (0-11) for the specified date.


Parameter Description
monthIntAn integer in the range 0-11. January=0, February=1 etc.
dayIntAn integer in the range 1-31.
  • If dayInt is not specified the value returned from the getUTCDate() method is used.
For specified values outside the ranges above the setUTCMonth() method will try and set the date accordingly.


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();

// Set UTC month.
alert(todaysDate + ' UTC Month set to 3');

// Set UTC month and day.
alert(todaysDate + ' UTC Month and day set');

Press the button below to action the above code:

Related Tutorials

JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times