Temporal.PlainYearMonth.prototype.month
Temporal.PlainYearMonth 例項的 month 訪問器屬性返回一個正整數,表示此年月中一年中的1基月份索引。這一年的第一個月是 1,最後一個月是 monthsInYear。它是 日曆相關的。
month 的 set 訪問器是 undefined。您不能直接更改此屬性。請使用 with() 方法建立一個具有所需新值的 Temporal.PlainYearMonth 新物件。
有關一般資訊和更多示例,請參見 Temporal.PlainDate.prototype.month。
示例
使用 month
js
const ym = Temporal.PlainYearMonth.from("2021-07"); // ISO 8601 calendar
console.log(ym.monthCode); // "M07"
console.log(ym.month); // 7
規範
| 規範 |
|---|
| Temporal # sec-get-temporal.plainyearmonth.prototype.month |
瀏覽器相容性
載入中…
另見
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