Temporal.PlainDate.prototype.toPlainYearMonth()
Temporal.PlainDate 例項的 toPlainYearMonth() 方法會返回一個新的 Temporal.PlainYearMonth 物件,該物件表示此日期在同一日曆系統中的 year(年)和 month(月)。
語法
js
toPlainYearMonth()
引數
無。
返回值
一個表示此日期在同一日曆系統中的 year(年)和 month(月)的新 Temporal.PlainYearMonth 物件。
示例
使用 toPlainYearMonth()
js
const date = Temporal.PlainDate.from("2021-07-01");
const yearMonth = date.toPlainYearMonth();
console.log(yearMonth.toString()); // 2021-07
規範
| 規範 |
|---|
| Temporal # sec-temporal.plaindate.prototype.toplainyearmonth |
瀏覽器相容性
載入中…