Temporal.ZonedDateTime.prototype.toInstant()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Phương thức toInstant() của các thực thể Temporal.ZonedDateTime trả về một đối tượng Temporal.Instant mới biểu thị thời điểm của ngày-giờ này.

Cú pháp

js
toInstant()

Tham số

Không có.

Giá trị trả về

Một đối tượng Temporal.Instant mới biểu thị thời điểm của ngày-giờ này.

Ví dụ

Sử dụng 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

Đặc tả

Specification
Temporal
# sec-temporal.zoneddatetime.prototype.toinstant

Tương thích trình duyệt

Xem thêm