How to use setUTCMilliseconds in JavaScript

In this article, I will explain use of setUTCMilliseconds() method in JavaScript date object.
  • 1454

JavaScript setUTCMilliseconds() method

  • setUTCMilliseconds() method of date object sets the milliseconds for a given date according to universal time.
  • setUTCMilliseconds() method is supported in all major browsers.

  • UTC is  The Universal Coordinated Time. it is the set by the World Time Standard.

  • UTC time is the same as GMT time.



  • Mili : Mili is optional parameter. A number is representing the milliseconds and it's value between 0 and 999.


In the following example show to setUTCMilliseconds() method set the milliseconds to 150 according to UTC.

<!DOCTYPE html>



<h3 style="color:ActiveBorder  ">JavaScript setUTCMilliseconds() Method Example</h3>

<p id="demo">Click for display the UTC milliseconds of a date time, after setting the UTC milliseconds.</p>

<button onclick="myFunction()">Click me</button>

<script type="text/javascript">

    function myFunction() {

        var d = new Date();


        var x = document.getElementById("demo");

        x.innerHTML ="After set the milliseconds time is : "+ d.getUTCMilliseconds();






UTCMilliseconds 1.jpg


UTCMilliseconds 2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.