Sets the year of the date. The year must be given with four digits (2007 instead of just 07).
var myDate = new Date();
/* w ww. j a v a 2 s . c o m*/
myDate.setFullYear(2012);
console.log(myDate.toString());
The code above generates the following result.