JavaScript setUTCMilliseconds

JavaScript setUTCMilliseconds function is a Date Function, which is used to set the Milliseconds of a specified date as per the universal time. The syntax of the JavaScript setUTCMilliseconds function is:

 Date.setUTCMilliseconds(Milliseconds)

JavaScript setUTCMilliseconds Function Example

We are using setUTCMilliseconds to set the current date Milliseconds to 500000 as per the universal time.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Set UTC Milliseconds Functions </title>
</head>
<body>
    <h1> JavaScript setUTCMilliseconds Function Example </h1>
<script>
  var dt = Date();  
  document.write("Date and Time : " + dt + "<br/>");

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

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

JavaScript set UTC Milliseconds Function Example 2

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

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Set UTC Milliseconds Functions </title>
</head>
<body>
    <h1> JavaScript setUTCMilliseconds Function Example </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