javascript subtract years from date
var myCurrentDate=new Date(); var myPastDate=new Date(myCurrentDate); myPastDate.setDate(myPastDate.getDate() - 8);//myPastDate is now 8 days in the past
Here is what the above code is Doing:
1. Create a new Date object called myCurrentDate.
2. Create a new Date object called myPastDate.
3. Set myPastDate to be 8 days in the past.