Temporal.PlainDateTime.prototype.dayOfWeek
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Thuộc tính accessor dayOfWeek của các instance Temporal.PlainDateTime trả về một số nguyên dương đại diện cho chỉ số ngày theo cơ số 1 trong tuần của ngày này. Các ngày trong tuần được đánh số tuần tự từ 1 đến daysInWeek, với mỗi số ánh xạ đến tên của nó. Nó phụ thuộc vào lịch.
Set accessor của dayOfWeek là undefined. Bạn không thể thay đổi thuộc tính này trực tiếp. Để tạo một đối tượng Temporal.PlainDateTime mới với giá trị dayOfWeek mong muốn, sử dụng phương thức add() hoặc subtract() với số days thích hợp.
Để biết thông tin chung và thêm ví dụ, xem Temporal.PlainDate.prototype.dayOfWeek.
Ví dụ
>Sử dụng dayOfWeek
js
const dt = Temporal.PlainDateTime.from("2021-07-01");
console.log(dt.dayOfWeek); // 4; Thursday
Đặc tả
| Specification |
|---|
| Temporal> # sec-get-temporal.plaindatetime.prototype.dayofweek> |
Tương thích trình duyệt
Xem thêm
Temporal.PlainDateTimeTemporal.PlainDateTime.prototype.with()Temporal.PlainDateTime.prototype.add()Temporal.PlainDateTime.prototype.subtract()Temporal.PlainDateTime.prototype.dayTemporal.PlainDateTime.prototype.dayOfYearTemporal.PlainDateTime.prototype.daysInWeekTemporal.PlainDateTime.prototype.weekOfYearTemporal.PlainDateTime.prototype.yearOfWeekTemporal.PlainDate.prototype.dayOfWeek