setFullYear()We can set or fix the year part of the data and time object by using setFullYear() function in JavaScript. This function will change the year part only.
x is four digit year.
Let us try one example.
Output is here
Setting the year part from present yearWe can set the year part by reading the present year using getYear function and then use set year part to set the year to a different value. Here is one example
Output is here
This article is written by plus2net.com team.
![]() |
▼ More on JavaScript Date |