大网数据广告活动
Web 标准与前端开发

Temporal.Instant() constructor

· 52CE 我爱测

The **`Temporal.Instant()`** constructor creates Temporal.Instant objects.

The Temporal.Instant() constructor creates Temporal.Instant objects.

This constructor is exactly equivalent to calling Temporal/Instant/fromEpochNanoseconds.

Syntax

new Temporal.Instant(epochNanoseconds)

[!NOTE] Temporal.Instant() can only be constructed with new. Attempting to call it without new throws a TypeError.

Parameters

  • epochNanoseconds
    • : A BigInt representing the number of nanoseconds since the Unix epoch.

Return value

A new Temporal.Instant object representing the instant in time specified by epochNanoseconds.

Exceptions

  • RangeError
    • : Thrown if epochNanoseconds represents an instant outside the range of representable instants, which is ±10<sup>8</sup> days, or about ±273,972.6 years, from the Unix epoch.

Examples

Using Temporal.Instant()

const instant = new Temporal.Instant(0n);
console.log(instant.toString()); // 1970-01-01T00:00:00Z
const vostok1Liftoff = new Temporal.Instant(-275248380000000000n);
console.log(vostok1Liftoff.toString()); // 1961-04-12T06:07:00Z
const sts1Liftoff = new Temporal.Instant(355924804000000000n);
console.log(sts1Liftoff.toString()); // 1981-04-12T12:00:04Z

Specifications

Browser compatibility

See also

  • Temporal.Instant
  • Temporal/Instant/epochNanoseconds
  • Temporal/Instant/from
  • Temporal/Instant/fromEpochMilliseconds
  • Temporal/Instant/fromEpochNanoseconds

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。