Temporal.ZonedDateTime.prototype.toInstant()
Temporal.ZonedDateTime 例項的 toInstant() 方法返回一個新的 Temporal.Instant 物件,表示此日期-時間所對應的瞬時。
語法
js
toInstant()
引數
無。
返回值
一個新的 Temporal.Instant 物件,表示此日期-時間所對應的瞬時。
示例
使用 toInstant()
js
const zdt = Temporal.ZonedDateTime.from(
"2021-07-01T12:34:56.987654321-04:00[America/New_York]",
);
const instant = zdt.toInstant();
console.log(instant.toString()); // 2021-07-01T16:34:56.987654321Z
規範
| 規範 |
|---|
| Temporal # sec-temporal.zoneddatetime.prototype.toinstant |
瀏覽器相容性
載入中…