Javascript Reference - JavaScript setMilliseconds() Method








setMilliseconds
Sets the date's milliseconds.

Browser Support

setMilliseconds() Yes Yes Yes Yes Yes

Syntax

dateObject.setMilliseconds(millisec);

Parameter Values

Parameter Description
millisec Required. An integer representing the milliseconds.
Expected values are 0-999, but other values are allowed:
-1 will be the last millisecond of the previous second.
1000 will be the first millisecond of the next second




Return Value

return a number, representing the number of milliseconds between the date object and midnight January 1 1970.

Example


      var myDate = new Date();
      
      myDate.setMilliseconds(123);
      console.log(myDate.toString());
      

The code above generates the following result.