Temporal.PlainDateTime.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 instance Temporal.PlainDateTime trả về một số nguyên đại diện cho số năm của ngày này tính từ đầu năm epoch của lịch cụ thể. Nó 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 dùng phương thức with() để tạo một đối tượng Temporal.PlainDateTime mới với giá trị mới mong muốn.
Để biết thông tin chung và thêm ví dụ, xem Temporal.PlainDate.prototype.year.
Ví dụ
>Sử dụng year
js
const dt = Temporal.PlainDateTime.from("2021-07-01"); // ISO 8601 calendar
console.log(dt.year); // 2021
Đặc tả
| Specification |
|---|
| Temporal> # sec-get-temporal.plaindatetime.prototype.year> |
Tương thích trình duyệt
Xem thêm
Temporal.PlainDateTimeTemporal.PlainDateTime.prototype.with()Temporal.PlainDateTime.prototype.add()Temporal.PlainDateTime.prototype.subtract()Temporal.PlainDateTime.prototype.eraTemporal.PlainDateTime.prototype.eraYearTemporal.PlainDateTime.prototype.yearOfWeekTemporal.PlainDateTime.prototype.monthTemporal.PlainDateTime.prototype.dayTemporal.PlainDate.prototype.year