JavaScript setUTCMilliseconds

JavaScript setUTCMilliseconds function is a Date Function, which is useful to set the Milliseconds of a specified date as per the universal time, and its syntax is:

 Date.setUTCMilliseconds(Milliseconds)

JavaScript setUTCMilliseconds Example

We are using setUTCMilliseconds function to set the current date Milliseconds to 500000 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.setUTCMilliseconds(500000);
  document.write("After : " + dt);
</script>
</body>
</html>
Example

Date and Time: Thu Nov 08 2018 12:19:19 GMT+0530 (Indian Standard Time)
After : Thu Nov 08 2018 12:27:39 GMT+0530 (Indian Standard Time)

In this JavaScript set UTC Milliseconds example, we set the custom date Milliseconds to 100000 according to universal time.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScriptSet UTC Milliseconds Functions </title>
</head>
<body>
    <h1> JavaScriptsetUTCMillisecondsFunctionExample </h1>
<script>
  var dt = Date("May 1, 2016 10:11:19");
  document.write("Date and Time : " + dt + "<br/>");

  dt.setUTCMilliseconds(100000);
  document.write("After setUTCMilliseconds() : " + dt);
</script>
</body>
</html>
JavaScript setUTCMilliseconds Example 2