Date.prototype.setTime()
Date
实例的 setTime()
方法更改了该日期的 timestamp,即自 epoch(定义为 UTC 1970 年 1 月 1 日开始的午夜)以来的毫秒数。
¥The setTime()
method of Date
instances changes the timestamp for this date, which is the number of milliseconds since the epoch, defined as the midnight at the beginning of January 1, 1970, UTC.
Try it
语法
参数
返回值
¥Return value
就地更改 Date
对象,并返回其新的 timestamp。如果 timeValue
是 NaN
(或获取 coerced 到 NaN
的其他值,例如 undefined
),则日期设置为 失效日期 并返回 NaN
。
¥Changes the Date
object in place, and returns its new timestamp. If timeValue
is NaN
(or other values that get coerced to NaN
, such as undefined
), the date is set to Invalid Date and NaN
is returned.
示例
使用 setTime()
规范
Specification |
---|
ECMAScript Language Specification # sec-date.prototype.settime |
浏览器兼容性
BCD tables only load in the browser