Temporal.ZonedDateTime.prototype.monthCode
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 monthCode của các thực thể Temporal.ZonedDateTime trả về một chuỗi đặc thù theo lịch biểu thị tháng của ngày này. Thuộc tính này phụ thuộc vào lịch.
Thông thường nó là M cộng với số tháng có hai chữ số. Đối với các tháng nhuận, nó là mã của tháng trước đó theo sau là L (ngay cả khi về mặt khái niệm nó là dẫn xuất của tháng tiếp theo; ví dụ, trong lịch Hebrew, Adar I có mã M05L nhưng Adar II có mã M06). Nếu tháng nhuận là tháng đầu tiên của năm, mã là M00L.
Set accessor của monthCode 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.monthCode.
Ví dụ
>Sử dụng monthCode
const date = Temporal.ZonedDateTime.from("2021-07-01[America/New_York]"); // ISO 8601 calendar
console.log(date.monthCode); // "M07"
console.log(date.month); // 7
Đặc tả
| Specification |
|---|
| Temporal> # sec-get-temporal.zoneddatetime.prototype.monthcode> |
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.yearTemporal.ZonedDateTime.prototype.monthTemporal.ZonedDateTime.prototype.daysInMonthTemporal.ZonedDateTime.prototype.monthsInYearTemporal.PlainDate.prototype.monthCode