JavaScript setUTCSeconds function is useful to set the Seconds and Milliseconds of a specified date as per the universal time, and its syntax is:
Date.setUTCSeconds(Seconds, Milliseconds)
setUTCSeconds Function Example
For this Date Function, Milliseconds is an optional argument. We are using setUTCSeconds to set the current date seconds to 49 as per the universal time.
<!DOCTYPE html>
<html>
<head>
<title> JS </title>
</head>
<body>
<h1> Example </h1>
<script>
var dt = Date();
document.write("Date and Time : " + dt + "<br/>");
dt.setUTCSeconds(49);
document.write("After : " + dt);
</script>
</body>
</html>
Example
Date and Time: Thu Nov 08 2018 12:13:07 GMT+0530 (Indian Standard Time)
After : Thu Nov 08 2018 12:13:49 GMT+0530 (Indian Standard Time)
In this JavaScript set UTC Seconds example, we set the custom date seconds to 55 according to universal time.
<!DOCTYPE html>
<html>
<head>
<title> JavaScriptSet UTC Seconds Functions </title>
</head>
<body>
<h1> JavaScriptsetUTCSecondsFunctionExample </h1>
<script>
var dt = Date("May 1, 2016 10:11:19");
document.write("Date and Time : " + dt + "<br/>");
dt.setUTCSeconds(55);
document.write("After setUTCSeconds() : " + dt);
</script>
</body>
</html>
