Temporal.ZonedDateTime.prototype.era

Limited availability

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

Thuộc tính accessor era của các thực thể Temporal.ZonedDateTime trả về một chuỗi chữ thường theo lịch cụ thể biểu thị era của ngày này, hoặc undefined nếu lịch không sử dụng era (ví dụ: ISO 8601). eraeraYear cùng nhau xác định duy nhất một năm trong lịch, theo cách tương tự như year. Giá trị này phụ thuộc vào lịch.

Set accessor của eraundefined. Bạn không thể thay đổi thuộc tính này trực tiếp. Sử dụng phương thức with() để tạo đối tượng Temporal.ZonedDateTime mới với giá trị mong muốn.

Để biết thêm thông tin chung và các ví dụ khác, xem Temporal.PlainDate.prototype.era.

Ví dụ

Sử dụng era

js
const dt = Temporal.ZonedDateTime.from("2021-07-01[America/New_York]"); // lịch ISO 8601
console.log(dt.era); // undefined

const dt2 = Temporal.ZonedDateTime.from(
  "2021-07-01[America/New_York][u-ca=gregory]",
);
console.log(dt2.era); // ce

Thông số kỹ thuật

Specification
Temporal
# sec-get-temporal.zoneddatetime.prototype.era

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

Xem thêm