JavaScript getUTCHours function is one of the Date Function, which returns the total number of the hours in a given date according to universal time. The syntax of the JavaScript getUTCHours function is:
Date.getUTCHours()
JavaScript getUTCHours Function Example
I am using the getUTCHours to return the total number of hours as per the universal time from the current date and time.
<!DOCTYPE html> <html> <head> <title> JavaScript Get UTC Hours Function </title> </head> <body> <h1> JavaScript getUTCHours Function Example </h1> <script> var dt = Date(); document.write("Date and Time : " + dt); document.write("UTC Hours using getUTCHours : " + dt.getUTCHours()); </script> </body> </html>
JavaScript get UTC Hours Function Example 2
In this JavaScript get UTC Hours example, we are displaying the universal time hours from the custom date
<!DOCTYPE html> <html> <head> <title> JavaScript Get UTC Hours Function </title> </head> <body> <h1> JavaScript getUTCHours Function Example </h1> <script> var dt = Date("April 2, 2017 10:11:22"); document.write("Date and Time : " + dt); document.write("UTC Hours using getUTCHours : " + dt.getUTCHours()); </script> </body> </html>