Date.setMilliseconds() (Method)

Sets the milliseconds value of the time object.

Availability:

ECMAScript edition - 2
JavaScript - 1.3
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.0
Property/method value type:Time value
JavaScript syntax:-myDate.setMilliseconds(aMillisecondValue)
Argument list:aMillisecondValuea value between 0 and 999 milliseconds

The computations are done based on extracting a local time value and changing the millisecond count for that, before storing it back again as a local time value.

The result of this method is the new time value having had the milliseconds component set according to the passed-in argument.

Example code:

   <HTML>
   <HEAD></HEAD>
   <BODY>
   <SCRIPT>
   myDate = new Date();
   myDate.setMilliseconds(0);
   myTime = myDate.getTime();
   document.write("The time rounded down to the nearest second is "  + myTime + " Milliseconds");
   </SCRIPT>
   </BODY>
   </HTML>

See also:Date.getMilliseconds(), Date.prototype, Date.setUTCMilliseconds()

Cross-references:

ECMA 262 edition 2 - section - 15.9.5.24

ECMA 262 edition 3 - section - 15.9.5.28