addMonths

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

addMonths(new Date(2016, 5, 1), 5); // 2016-11-1
addMonths(new Date(2016, 5, 1), -5); // 2015-1-1

Parameters

date Date

The initial date value.

offset number

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

Returns

Date - A new Date instance.

 /