JavaScript getUTCMonth function is one of the Date Function, which returns the Month Number on a given date according to universal time. Month Number starts from 0 (January) and ends at 11 (December). The syntax of the JavaScript getUTCMonth function is:
Date.getUTCMonth()
JavaScript getUTCMonth Function Example
Here, we used the getUTCMonth function to return the month number as per the universal time from the current date and time.
<!DOCTYPE html> <html> <head> <title> JavaScript Get UTC Month Function </title> </head> <body> <h1> JavaScript getUTCMonth Function Example </h1> <script> var dt = Date(); document.write("Date and Time : " + dt); document.write("UTC Month using getUTCMonth : " + dt.getUTCMonth()); </script> </body> </html>
JavaScript get UTC Month Function Example 2
In this JavaScript get UTC Month example, we are displaying the month number from the custom date and time as per universal time.
<!DOCTYPE html> <html> <head> <title> JavaScript Get UTC Month Function </title> </head> <body> <h1> JavaScript getUTCMonth Function Example </h1> <script> var dt = Date("April 1, 2017 10:12:22"); document.write("Date and Time : " + dt); document.write("UTC Month using getUTCMonth : " + dt.getUTCMonth()); </script> </body> </html>