Temporal.PlainYearMonth.prototype.month
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Thuộc tính truy cập month của các thực thể Temporal.PlainYearMonth trả về một số nguyên dương đại diện cho chỉ số tháng bắt đầu từ 1 trong năm của year-month này. Tháng đầu tiên của năm này là 1, và tháng cuối cùng là monthsInYear. Nó phụ thuộc vào lịch.
Set accessor của month là undefined. Bạn không thể thay đổi thuộc tính này trực tiếp. Dùng phương thức with() để tạo một đối tượng Temporal.PlainYearMonth mới với giá trị mong muốn.
Để biết thông tin chung và thêm ví dụ, xem Temporal.PlainDate.prototype.month.
Ví dụ
>Sử dụng month
js
const ym = Temporal.PlainYearMonth.from("2021-07"); // ISO 8601 calendar
console.log(ym.monthCode); // "M07"
console.log(ym.month); // 7
Đặc tả
| Specification |
|---|
| Temporal> # sec-get-temporal.plainyearmonth.prototype.month> |
Tương thích trình duyệt
Xem thêm
Temporal.PlainYearMonthTemporal.PlainYearMonth.prototype.with()Temporal.PlainYearMonth.prototype.add()Temporal.PlainYearMonth.prototype.subtract()Temporal.PlainYearMonth.prototype.yearTemporal.PlainYearMonth.prototype.monthCodeTemporal.PlainYearMonth.prototype.daysInMonthTemporal.PlainYearMonth.prototype.monthsInYearTemporal.PlainDate.prototype.month