Home >>JavaScript Date Object Methods >JavaScript getUTCMonth() Method
The getUTCMonth() method method in JavaScript returns the month (from 0 to 11) in the specified date according to universal time. The value returned by getUTCMonth() is an integer between 0 to 11 [January is 0, February is 1, and so on].
Syntax:Date.getUTCMonth()
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
getUTCMonth() | Yes | Yes | Yes | Yes | Yes |
<html> <body> <button onclick="mygetmonth()">click me</button> <p id="month"></p> <script> function mygetmonth() { var d = new Date(); var z = d.getUTCMonth(); document.getElementById("month").innerHTML = z; } </script> </body> </html>
<html> <body> <script> var dateobj = new Date('July 5, 1997 22:02:25 GMT+11:00'); var M = dateobj.getUTCMonth(); document.write(M); </script> </body> </html>