Javascript Date setMilliseconds (milliseconds) rets the date's milliseconds.
dateObj.setMilliseconds(millisecondsValue)
millisecondsValue
- A number between 0 and 999, representing the milliseconds.The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.
If millisecondsValue
is outside the expected range, the date is updated accordingly.
let d = new Date(); console.log(d);//from w w w .j a v a2 s . c o m d.setMilliseconds(100); console.log(d); d.setMilliseconds(10000); console.log(d);
Set both the seconds and milliseconds:
var d = new Date(); d.setSeconds(35, 825);/* w w w. java 2 s. c o m*/ var s = d.getSeconds(); var ms = d.getMilliseconds(); console.log(s + ":" + ms);