Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

setMilliseconds Method (Date) (JavaScript)

Sets the milliseconds value in the Date object using local time.

dateObj.setMilliseconds(numMilli)
dateObj

Required. Any Date object.

numMilli

Required. A numeric value equal to the millisecond value.

To set the milliseconds value using 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;                    // Declare variables.
   d = new Date();              // Create Date object.
   d.setMilliseconds(nmsec);    // Set milliseconds.
   s = "Current setting is ";
   s += d.toLocaleString();
   s += " and " + d.getMilliseconds();
   s += " milliseconds";
   return(s);                   // Return new date setting.
}

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Applies To: Date Object (JavaScript)

Show:
© 2014 Microsoft. All rights reserved.