Javascript Reference - JavaScript getMilliseconds() Method








getMilliseconds()
Returns the date's milliseconds(from 0 to 999).

Browser Support

getMilliseconds() Yes Yes Yes Yes Yes

Syntax

dateObject.getMilliseconds();

Parameters

None

Return Value

return a number from 0 to 999 representing milliseconds.

Example


var myDate = new Date();
console.log(myDate.getMilliseconds());

The code above generates the following result.





Example 2

The following code returns the milliseconds from a specific date and time:


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!--from   ww  w.  j  av  a2s.  c o m-->
<script>
function myFunction() {
    var d = new Date("July 12, 1956 01:78:00:526");
    var n = d.getMilliseconds();
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

The code above is rendered as follows: