C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Date getUTCMonth() methodThe JavaScript date getUTCMonth() method returns the integer value that represents month for the specified date on the basis of universal time. The value returned by getUTCMonth() method starts with 0 that represents January. SyntaxThe getUTCMonth() method is represented by the following syntax: dateObj.getUTCMonth() ReturnAn integer value between 0 and 11 that represents the month in the specified date. JavaScript Date getUTCMonth() method exampleHere, we will understand getUTCMonth() method through various examples. Example 1Let's see an example to print current month according to universal time. <script> var month=new Date(); document.writeln("Month value : "+(month.getUTCMonth()+1)); </script> Output: Month value : 8 Example 2Let's see an example to print the month from the given date according to universal time. <script> var month1=new Date("August 31, 1947 20:22:10 GMT+12:00"); var month2=new Date("August 31, 1947 20:22:10 GMT-12:00"); document.writeln("Month value1 : "+(month1.getUTCMonth()+1)+"<br>"); document.writeln("Month value2 : "+(month2.getUTCMonth()+1)); </script> Output: Test it NowMonth value1 : 8 Month value2 : 9
Next TopicJavaScript Date
|