Temporal.ZonedDateTime.prototype.calendarId

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 calendarId của các instance Temporal.ZonedDateTime trả về một chuỗi biểu diễn calendar được sử dụng để diễn giải ngày ISO 8601 nội bộ.

Xem Intl.supportedValuesOf() để biết danh sách các loại calendar thường được hỗ trợ.

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

Ví dụ

Sử dụng calendarId

js
const dt = Temporal.ZonedDateTime.from(
  "2021-07-01T08:00:00-04:00[America/New_York]",
);
console.log(dt.calendarId); // "iso8601"; default

const dt2 = Temporal.ZonedDateTime.from(
  "2021-07-01T08:00:00+08:00[Asia/Shanghai][u-ca=chinese]",
);
console.log(dt2.calendarId); // "chinese"

const dt3 = dt2.withCalendar("hebrew");
console.log(dt3.calendarId); // "hebrew"

Đặc tả kỹ thuật

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

Khả năng tương thích với trình duyệt

Xem thêm