Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript setUTCMilliseconds() Method

JavaScript setUTCMilliseconds() Method

Date Object Reference 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();

n Output result:

Try it »


Definition and Usage

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

**Note:** Coordinated Universal Time, also known as Universal Time, Universal Standard Time, or International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).

**Note:** 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 value

Parameters Description
millisec Required. The value to set for the milliseconds field of 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 from midnight on January 1, 1970 to the time at which the specified milliseconds are set.

    Technical Details

    JavaScript version: 1.3

    Date Object Reference JavaScript Date object