JavaScript Tarih setiTamYıl ()
örnek 1
const d = yeni Tarih();
d.setFullYear(2020);
Tanım ve Kullanım
setFullYear()
bir tarihin yılını ayarlar.
setFullYear()
ay ve günü de ayarlayabilir.
Örnek 2
const d = new Date();
d.setFullYear(2020, 10, 3);
Örnek 3
Tarihi altı ay öncesine ayarlayın :
const d = new Date();
d.setFullYear(d.getFullYear(), d.getMonth() - 6);
Tarayıcı Desteği
setFullYear()
bir ECMAScript1 (ES1) özelliğidir.
ES1 (JavaScript 1997) tüm tarayıcılarda tam olarak desteklenir:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Sözdizimi
Date.setFullYear(year, month, day)
parametreler
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:
|
Geri dönüş değeri
Bir sayı. Tarih ile 1 Ocak 1970 00:00:00 UTC arasındaki milisaniye sayısı. |