English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript setFullYear() method

 JavaScript Date-Objekt

DassetFullYear()Method, sets the full year (four-digit year is four digits) for the specified date object according to the local time.

This method can also be used to set the month and day of the month.

If the specified parameters are out of the expected range, thensetFullYear()Try to update other parameters and date information in the Date object accordingly.

For example, if you setmonthValue specification16 ,则年份将增加1(年份值+ 1),而月份将使用4.

Syntax:

date.setFullYear(year, month, day)
var d = new Date();
d.setFullYear(2010);
Testen Sie heraus‹/›

If not specifiedmonthanddayParameter, then use the values returned by getMonth() and getDate() methods.

Browserkompatibilität

setFullYear()-Methode wird von allen Browsern vollständig unterstützt:

Methode
setFullYear()ististististist

Parameterwert

ParameterBeschreibung
yearErforderlich) eine Ganzzahl, die den Wert des Jahres angibt, z.B.1992
monthOptional) eine Ganzzahl zwischen11bis
dayOptional) eine Ganzzahl zwischen1bis31eine Ganzzahl zwischen
Hinweis:wenn spezifiziertdayParameter, dann muss auchmonthParameter.

Technische Details

Rückgabewert:1970 Jahren1Monat1Millisekunden zwischen dem Datum 00:00:00 UTC und dem Aktualisierungsdatum
JavaScript-Version:ECMAScript 1

Mehr Beispiele

bestimmen16als Monatswert:

var d = new Date();
d.setFullYear(2010, 16);
Testen Sie heraus‹/›

DasAufruf von setFullYear()Methoden können den Monat und das Datum festlegen:

var d = new Date();
d.setFullYear(2010, 8, 30);
Testen Sie heraus‹/›

 JavaScript Date-Objekt