Latest web development tutorials

JavaScript setUTCMilliseconds () method

Date Object Reference JavaScript Date Object

Examples

According to Universal Time (UTC) setting specifies the number of milliseconds to 192:

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

n output:


try it"

Definition and Usage

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

Tip: Coordinated Universal Time, also known as the unified world time, Universal Time, Coordinated Universal Time, abbreviated UTC (Universal Coordinated Time).

Tip: UTC time is the GMT (Greenwich Mean) time.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support setUTCMilliseconds () method.


grammar

Date.setUTCMilliseconds( millisec )

Parameter Value

参数 描述
millisec 必需。要给 dateObject 设置的毫秒字段的值。使用世界时表示。

该参数是 0 ~ 999 之间的整数:

  • -1 为上一秒钟的最后1毫秒
  • 1000 为下一秒中的第一毫秒
  • 1001 为下一秒中的第二毫秒

return value

Type 描述
Number 返回 1970 年 1月 1日 午夜至设置指定毫秒数时间之间的毫秒数。

technical details

JavaScript version: 1.3


Date Object Reference JavaScript Date Object