JavaScript getUTCDay function is one of the Date Function, which returns the day number of a given date according to universal time. Day Number starts at 0 and ends at 6, where 0 as of Sunday, six as Saturday. The syntax of the JavaScript getUTCDay function is:
Date.getUTCDay()
JavaScript getUTCDay Function Example
Here, we are using getUTCDay to return the day number from the current date and time.
<!DOCTYPE html> <html> <head> <title> JavaScript Get UTC Day Function </title> </head> <body> <h1> JavaScript getUTCDay Function Example </h1> <script> var dt = Date(); document.write("Date and Time : " + dt); document.write("UTC Day using getUTCDay : " + dt.getUTCDay()); </script> </body> </html>
OUTPUT
JavaScript get UTC Day Function Example
In this JavaScript getUTCDay function example, we are displaying the day number from the custom date
<!DOCTYPE html> <html> <head> <title> JavaScript Get UTC Day Function </title> </head> <body> <h1> JavaScript getUTCDay Function Example </h1> <script> var dt = Date("April 1, 2016 10:14:22"); document.write("Date and Time : " + dt); document.write("UTC Day using getUTCDay : " + dt.getUTCDay()); </script> </body> </html>
OUTPUT