Temporal.ZonedDateTime.prototype.year
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 year của các thực thể Temporal.ZonedDateTime trả về một số nguyên biểu thị số năm của ngày này so với năm epoch đặc thù theo lịch. Thuộc tính này phụ thuộc vào lịch.
Set accessor của year là undefined. Bạn không thể thay đổi thuộc tính này trực tiếp. Hãy sử dụng phương thức with() để tạo một đố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, hãy xem Temporal.PlainDate.prototype.year.
Ví dụ
>Sử dụng year
js
const dt = Temporal.ZonedDateTime.from("2021-07-01[America/New_York]"); // ISO 8601 calendar
console.log(dt.year); // 2021
Đặc tả
| Specification |
|---|
| Temporal> # sec-get-temporal.zoneddatetime.prototype.year> |
Tương thích trình duyệt
Xem thêm
Temporal.ZonedDateTimeTemporal.ZonedDateTime.prototype.with()Temporal.ZonedDateTime.prototype.add()Temporal.ZonedDateTime.prototype.subtract()Temporal.ZonedDateTime.prototype.eraTemporal.ZonedDateTime.prototype.eraYearTemporal.ZonedDateTime.prototype.yearOfWeekTemporal.ZonedDateTime.prototype.monthTemporal.ZonedDateTime.prototype.dayTemporal.PlainDate.prototype.year