How to use setUTCMilliseconds in JavaScript
In this article, I will explain use of setUTCMilliseconds() method in JavaScript date object.
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.
Syntax
Date.setUTCMilliseconds(millisec)
|
Example
In the following example show to setUTCMilliseconds() method set the milliseconds to 150 according to UTC.
<!DOCTYPE html>
<html>
<body>
<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();
d.setUTCMilliseconds(150);
var x = document.getElementById("demo");
x.innerHTML ="After set the milliseconds time is : "+ d.getUTCMilliseconds();
}
</script>
</body>
</html>
|
Output1

Output2

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