addMonths static method

DateTime addMonths(
  1. DateTime date,
  2. int months
)

Add months to a date

date - The base date months - Number of months to add (can be negative to subtract) Returns new DateTime object

Implementation

static DateTime addMonths(DateTime date, int months) {
  return DateTime(date.year, date.month + months, date.day);
}