Temporal.PlainDateTime.prototype.year
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Die year Accessor-Eigenschaft von Temporal.PlainDateTime Instanzen gibt eine Ganzzahl zurück, die die Anzahl der Jahre dieses Datums relativ zum Beginn eines kalender-spezifischen Epochejahres darstellt. Sie ist kalenderabhängig.
Der set-Accessor von year ist undefined. Sie können diese Eigenschaft nicht direkt ändern. Verwenden Sie die Methode with(), um ein neues Temporal.PlainDateTime Objekt mit dem gewünschten neuen Wert zu erstellen.
Für allgemeine Informationen und weitere Beispiele siehe Temporal.PlainDate.prototype.year.
Beispiele
>Verwendung von year
js
const dt = Temporal.PlainDateTime.from("2021-07-01"); // ISO 8601 calendar
console.log(dt.year); // 2021
Spezifikationen
| Specification |
|---|
| Temporal> # sec-get-temporal.plaindatetime.prototype.year> |
Browser-Kompatibilität
Siehe auch
Temporal.PlainDateTimeTemporal.PlainDateTime.prototype.with()Temporal.PlainDateTime.prototype.add()Temporal.PlainDateTime.prototype.subtract()Temporal.PlainDateTime.prototype.eraTemporal.PlainDateTime.prototype.eraYearTemporal.PlainDateTime.prototype.yearOfWeekTemporal.PlainDateTime.prototype.monthTemporal.PlainDateTime.prototype.dayTemporal.PlainDate.prototype.year