Javascript examples for Date:setMilliseconds
The setMilliseconds() method sets the milliseconds of a date object.
date.setMilliseconds(millisec)
Parameter | Description |
---|---|
millisec | Required. An integer representing the milliseconds |
Expected values are 0-999, but other values are allowed:
A Number, representing the number of milliseconds between the date object and midnight January 1 1970
The following code shows how to Set the milliseconds to 192:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*ww w.j av a 2s .c om*/ var d = new Date(); d.setMilliseconds(192); var n = d.getMilliseconds(); document.getElementById("demo").innerHTML = n; } </script> </body> </html>