JavaScript getUTCSeconds function is one of the Date Function, which returns the total seconds on a given date according to universal time. The syntax of the JavaScript getUTCSeconds function is:
Date.getUTCSeconds()
JavaScript getUTCSeconds Function Example
We use getUTCSeconds to return the total seconds as per the universal time from the current date and time.
<!DOCTYPE html> <html> <head> <title> JavaScript Get UTC Seconds Function </title> </head> <body> <h1> Example </h1> <script> var dt = Date(); document.write("Date and Time : " + dt); document.write("UTC Seconds : " + dt.getUTCSeconds()); </script> </body> </html>
Example
Date and Time: Mon Nov 05 2018 11:11:38 GMT+0530 (Indian Standard Time)
UTC Seconds : 38
JavaScript get UTC Seconds Example 2
In this JavaScript example for getUTCSeconds, we are displaying the seconds from the custom date and time as per universal time.
<!DOCTYPE html> <html> <head> <title> JavaScript Get UTC Seconds Function </title> </head> <body> <h1> JavaScript getUTCSeconds Function Example </h1> <script> var dt = Date("April 2, 2017 10:02:22"); document.write("Date and Time : " + dt); document.write("UTC Seconds using getUTCSeconds : " + dt.getUTCSeconds()); </script> </body> </html>
