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 |
浏览器兼容性
加载中…