getMilliseconds()
Returns the date's milliseconds(from 0 to 999).
getMilliseconds() |
Yes | Yes | Yes | Yes | Yes |
dateObject.getMilliseconds();
None
return a number from 0 to 999 representing milliseconds.
var myDate = new Date();
console.log(myDate.getMilliseconds());
The code above generates the following result.
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: