Microsoft® JScript setMilliseconds Method |
Language Reference Version 3 |
Modifies the milliseconds value stored in the Date object according to local time.
objDate.setMilliseconds(numMilli)The numMilli argument is a numeric value equal to the millisecond value.
All set methods taking optional arguments use the value returned from corresponding get methods, if you do not specify an optional argument. For example, if the numMonth argument is optional, but not specified, JScript uses the value returned from the getMonth method.To set the milliseconds value according to Universal Coordinated Time (UTC), use the setUTCMilliseconds method.
If the value of numMilli is greater than 999 or is a negative number, the stored number of seconds (and minutes, hours, and so forth if necessary) is incremented an appropriate amount.
The following example illustrates the use of the setMilliseconds method:
function SetMSecDemo(nmsec) { var d, s; var sep = ":"; d = new Date(); d.setMilliseconds(nmsec); s = "Current setting is "; s += d.toLocaleString() + sep + d.getMilliseconds(); return(s); }