I want to create a Date object in javascript, which represents the year 0001, 2014 years ago.
I tried with
d = new Date(); d.setYear(1);
console.log
The (deprecated) Date.setYear method sets the year for a specified date, but note that:
If yearValue is a number between 0 and 99 (inclusive), then the year for dateObj is set to 1900 + yearValue. Otherwise, the year for dateObj is set to yearValue.
var theBigDay = new Date(); theBigDay.setYear(96); // sets year to 1996 theBigDay.setYear(1996); // sets year to 1996 theBigDay.setYear(2000); // sets year to 2000
You should use Date.setFullYear method nevertheless. The other method is deprecated.