Temporal.PlainDate.prototype.toPlainYearMonth()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Phương thức toPlainYearMonth() của các instance Temporal.PlainDate trả về một đối tượng Temporal.PlainYearMonth mới đại diện cho yearmonth của ngày này trong cùng hệ thống lịch.

Cú pháp

js
toPlainYearMonth()

Tham số

Không có.

Giá trị trả về

Một đối tượng Temporal.PlainYearMonth mới đại diện cho yearmonth của ngày này trong cùng hệ thống lịch.

Ví dụ

Sử dụng toPlainYearMonth()

js
const date = Temporal.PlainDate.from("2021-07-01");
const yearMonth = date.toPlainYearMonth();
console.log(yearMonth.toString()); // 2021-07

Đặc tả

Specification
Temporal
# sec-temporal.plaindate.prototype.toplainyearmonth

Tương thích trình duyệt

Xem thêm