setUTCMilliseconds Method (JavaScript)

Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).



Required. Any Date object.


Required. A numeric value equal to the millisecond value.

To set the milliseconds using local time, use the setMilliseconds 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 setUTCMilliseconds method.

function SetUTCMSecDemo(nmsec){   
// Create Date object.
   var d = new Date();           
// Set UTC milliseconds.

   var s = "Current setting is ";
   s += d.toUTCString();
   s += " and " + d.getUTCMilliseconds();
   s += " milliseconds"

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

Applies To: Date Object (JavaScript)