Temporal.PlainDateTime.prototype.toPlainDate()

Limited availability

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

Phương thức toPlainDate() của các instance Temporal.PlainDateTime trả về một đối tượng Temporal.PlainDate mới đại diện cho phần ngày (năm, tháng, ngày) của ngày-giờ này trong cùng hệ thống lịch.

Cú pháp

js
toPlainDate()

Tham số

Không có.

Giá trị trả về

Một đối tượng Temporal.PlainDate mới đại diện cho phần ngày (năm, tháng, ngày) của ngày-giờ này trong cùng hệ thống lịch.

Ví dụ

Sử dụng toPlainDate()

js
const dt = Temporal.PlainDateTime.from("2021-07-01T12:34:56");
const date = dt.toPlainDate();
console.log(date.toString()); // '2021-07-01'

Đặc tả

Specification
Temporal
# sec-temporal.plaindatetime.prototype.toplaindate

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

Xem thêm