Data ustawienia JavaScriptPełny rok ()
Przykład 1
const d = nowa Data();
d.ustawPełnyRok(2020);
Definicja i użycie
setFullYear()
ustawia rok daty.
setFullYear()
można również ustawić miesiąc i dzień.
Przykład 2
const d = new Date();
d.setFullYear(2020, 10, 3);
Przykład 3
Ustaw datę na sześć miesięcy temu :
const d = new Date();
d.setFullYear(d.getFullYear(), d.getMonth() - 6);
Obsługa przeglądarki
setFullYear()
to funkcja ECMAScript1 (ES1).
ES1 (JavaScript 1997) jest w pełni obsługiwany we wszystkich przeglądarkach:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Składnia
Date.setFullYear(year, month, day)
Parametry
year | Required. The year. Negative values are allowed. |
month | Optional. The month (0 to 11). Higher and lower values are handeled with date maths:
|
day | Optional. The day (0 to 31). Higher and lower values are handeled with date maths:
|
Wartość zwrotu
Numer. Liczba milisekund między datą a 1 stycznia 1970 00:00:00 UTC. |