Home >>JavaScript Date Object Methods >JavaScript setUTCMilliseconds() Method
JavaScript setUTCMilliseconds() method is used to set the milliseconds according to the universal time (UTC). As a result it return an integer having value between 0 to 999.
Syntax:Date.setUTCMilliseconds(millisec)
Parameter | Description |
---|---|
millisec | This is a required parameter. It defines an integer representing the milliseconds. |
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
setUTCMilliseconds() | Yes | Yes | Yes | Yes | Yes |
<html> <body> <p>Click the button to see the Output.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var d = new Date(); d.setUTCMilliseconds(100); var n = d.getUTCMilliseconds(); document.getElementById("demo").innerHTML = n; } </script> </body> </html>
Click the button to see the Output.
<html> <body> <p>Click the button to see the Output.</p> <button onclick="myFunction1()">Try it</button> <p id="demo1"></p> <script> function myFunction1() { var d = new Date(); d.setUTCMilliseconds(150); var n = d.getUTCMilliseconds(); document.getElementById("demo1").innerHTML = n; } </script> </body> </html>
Click the button to see the Output.