JavaScript setUTCMilliseconds()Method

Date 对象参考手册JavaScript Date Object

Example

Set the specified milliseconds to 192 according to Universal Time (UTC):

var d = new Date();
d.setUTCMilliseconds(192);
var n = d.getUTCMilliseconds();

nOutput:


Try it Yourself »

Definition and Usage

The setUTCMilliseconds() method is used to set the milliseconds of a specified time according to Universal Time (UTC).

Tip:Coordinated Universal Time, also known as World Unified Time, World Standard Time, International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).

Tip:UTC time is the same as GMT (Greenwich) time.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the setUTCMilliseconds() method.


Syntax

Date.setUTCMilliseconds(millisec)

Parameter Values

Parameter Description
millisec Required. The value of the milliseconds field to be set for the dateObject. Expressed in Universal Time.

This parameter is an integer between 0 and 999:

  • -1 is the last millisecond of the previous second
  • 1000 is the first millisecond of the next second
  • 1001 is the second millisecond of the next second

Return Value

Type Description
Number Returns the number of milliseconds between midnight on January 1, 1970 and the time with the specified milliseconds set.

Technical Details

JavaScript Version: 1.3


Date 对象参考手册JavaScript Date Object

Other Extensions