Temporal.PlainDateTime.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 accessor month của các instance Temporal.PlainDateTime trả về một số nguyên dương đại diện cho chỉ số tháng theo cơ số 1 trong năm của ngày này. Tháng đầu tiên của năm 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. Sử 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.month.
Ví dụ
>Sử dụng month
js
const dt = Temporal.PlainDateTime.from("2021-07-01"); // ISO 8601 calendar
console.log(dt.monthCode); // "M07"
console.log(dt.month); // 7
Đặc tả
| Specification |
|---|
| Temporal> # sec-get-temporal.plaindatetime.prototype.month> |
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.yearTemporal.PlainDateTime.prototype.dayTemporal.PlainDateTime.prototype.monthCodeTemporal.PlainDateTime.prototype.daysInMonthTemporal.PlainDateTime.prototype.monthsInYearTemporal.PlainDate.prototype.month