Date getMilliseconds() Method - Javascript Date

Javascript examples for Date:getMilliseconds

Description

The getMilliseconds() method returns the milliseconds from 0 to 999.

Parameters

None

Return Value:

A Number, from 0 to 999, representing milliseconds

The following code shows how to return the milliseconds.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//w  w  w.  j  a  v  a 2  s  .c  om
    var d = new Date("July 21, 2020 01:15:00:123");
    var n = d.getMilliseconds();
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

Related Tutorials