JavaScript Date setUTCMilliseconds() Method

Definition and Usage

setUTCMilliseconds() The method sets milliseconds according to world time (from 0 to 999).

Tip:Coordinated Universal Time (UTC) is the time set by the world time standard.

Note:UTC time is the same as GMT time (Greenwich Mean Time).

Example

Set milliseconds to 192 according to UTC time:

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

Try It Yourself

Syntax

Date.setUTCMilliseconds(millisec)

Parameter Value

Parameter Description
millisec

Required. An integer representing milliseconds.

The expected value is 0-999, but other values are allowed:

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

Technical Details

Return Value: A number representing the milliseconds between the date object and midnight on January 1, 1970.
JavaScript Version: ECMAScript 1

Browser Support

Method Chrome IE Firefox Safari Opera
setUTCMilliseconds() Support Support Support Support Support

Related Pages

Tutorial:JavaScript Date

Tutorial:JavaScript Date Format

Tutorial:JavaScript Date Setting Methods