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.
setFullYear(x);
x is four digit year.
Let us try one example.
<script type="text/javascript">
var dt= new Date();
document.write(dt + "<br><br>");
dt.setFullYear(2015);
document.write(dt);
</script>
Output is here
Setting the year part from present year
We 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
<script type="text/javascript">
var dt= new Date();
document.write(dt + "<br><br>");
var new_year=dt.getFullYear() + 10
dt.setFullYear(new_year);
document.write(dt);
</script>