Temporal.ZonedDateTime.prototype.dayOfYear
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 dayOfYear của các instance Temporal.ZonedDateTime trả về một số nguyên dương biểu diễn chỉ số ngày dựa trên 1 trong năm của ngày này. Ngày đầu tiên của năm là 1, và ngày cuối cùng là daysInYear. Giá trị này phụ thuộc vào calendar.
Set accessor của dayOfYear 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.ZonedDateTime mới với giá trị dayOfYear mong muốn, hãy dùng phương thức add() hoặc subtract() với số lượng days phù hợp.
Để biết thêm thông tin chung và ví dụ, hãy xem Temporal.PlainDate.prototype.dayOfYear.
Ví dụ
>Sử dụng dayOfYear
js
const dt = Temporal.ZonedDateTime.from("2021-07-01[America/New_York]");
console.log(dt.dayOfYear); // 182
Đặc tả kỹ thuật
| Specification |
|---|
| Temporal> # sec-get-temporal.zoneddatetime.prototype.dayofyear> |
Khả năng tương thích với trình duyệt
Xem thêm
Temporal.ZonedDateTimeTemporal.ZonedDateTime.prototype.with()Temporal.ZonedDateTime.prototype.add()Temporal.ZonedDateTime.prototype.subtract()Temporal.ZonedDateTime.prototype.yearTemporal.ZonedDateTime.prototype.dayTemporal.ZonedDateTime.prototype.dayOfWeekTemporal.ZonedDateTime.prototype.daysInYearTemporal.PlainDate.prototype.dayOfYear