JavaScript Ngày đặtFullYear()
Sự miêu tả
setFullYear()
đặt năm của một ngày.
setFullYear()
cũng có thể đặt tháng và ngày.
Ví dụ 3
Đặt ngày thành sáu tháng trước :
const d = new Date();
d.setFullYear(d.getFullYear(), d.getMonth() - 6);
Hãy tự mình thử »Hỗ trợ trình duyệt
setFullYear()
là tính năng ECMAScript1 (ES1).
ES1 (JavaScript 1997) được hỗ trợ đầy đủ trên tất cả các trình duyệt:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
Cú pháp
Date .setFullYear( year , month , day )
Thông số
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:
|
Giá trị trả về
Một số. Số mili giây giữa ngày và ngày 1 tháng 1 năm 1970 00:00:00 UTC. |