Date.prototype.getUTCMilliseconds()

Date 实例的 getUTCMilliseconds() 方法根据世界时间返回该日期的毫秒数。

¥The getUTCMilliseconds() method of Date instances returns the milliseconds for this date according to universal time.

Try it

语法

¥Syntax

js
getUTCMilliseconds()

参数

¥Parameters

没有任何。

¥None.

返回值

¥Return value

0 到 999 之间的整数,表示根据通用时间给定日期的毫秒数。如果日期是 invalid,则返回 NaN

¥An integer, between 0 and 999, representing the milliseconds for the given date according to universal time. Returns NaN if the date is invalid.

不要与时间戳混淆。要获取自纪元以来的总毫秒数,请使用 getTime() 方法。

¥Not to be confused with the timestamp. To get the total milliseconds since the epoch, use the getTime() method.

示例

¥Examples

使用 getUTCMilliseconds()

¥Using getUTCMilliseconds()

以下示例将当前时间的毫秒部分分配给变量 milliseconds

¥The following example assigns the milliseconds portion of the current time to the variable milliseconds.

js
const today = new Date();
const milliseconds = today.getUTCMilliseconds();

规范

Specification
ECMAScript Language Specification
# sec-date.prototype.getutcmilliseconds

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看