The getUTCMonth method returns, according to universal time, the month of the point in stored in a Date object. The value returned by this method is an integer number from 0 to 11, zero being January and eleven being December.
Syntax
myDate.getUTCMonth()
With myDate being an object based on the Date object.
Instead of being instantiated from a class, in JavaScript objects are created by replicating other objects. This paradigm is called Prototype-based programming.
Example
The following code uses the getUTCMonth method to return the month of the current date according to universal time.
<script type="text/javascript">
function getMonthName(monthNumber)
{
var monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
return monthNames[monthNumber];
}
var currentDate = new Date();
var universalMonthNumber = currentDate.getUTCMonth();
var nameOfTheMonth = getMonthName(universalMonthNumber);
document.write("According to universal time the number of the current month is " + universalMonthNumber + ", which means it is " + nameOfTheMonth + ".");
</script>
function getMonthName(monthNumber)
{
var monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
return monthNames[monthNumber];
}
var currentDate = new Date();
var universalMonthNumber = currentDate.getUTCMonth();
var nameOfTheMonth = getMonthName(universalMonthNumber);
document.write("According to universal time the number of the current month is " + universalMonthNumber + ", which means it is " + nameOfTheMonth + ".");
</script>
Technical Details
The getUTCMonth method belongs to the Date object, it is available since the version 1.3 of JavaScript, and it is supported in all major browsers.
JavaScript Manual >> Date Object >> getUTCMonth Method