addYears

A function that adds and subtracts years from a Date object.

addYears(new Date(2016, 5, 1), 5); // 2011-6-1
addYears(new Date(2016, 5, 1), -5); // 2021-6-1

Parameters

value Date
offset number

The number of years to add or subtract from the date.

Returns

Date - A new Date instance.

 /