getUTCMonth()
Returns the month of the UTC date,
where 0 represents January and 11 represents December.
UTC time is the same as GMT time.
getUTCMonth() |
Yes | Yes | Yes | Yes | Yes |
dateObject.getUTCMonth();
None.
return a number, from 0-11, representing the month.
var myDate = new Date();
console.log(myDate.getUTCMonth());
The code above generates the following result.
The following code return the name of the month defined in an array, according to universal time.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!-- w ww.j av a2 s . c o m-->
var d = new Date();
var month = new Array(12);
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var n = month[d.getUTCMonth()];
document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>
The code above is rendered as follows: