addMonths method

  1. @useResult
DateTime addMonths(
  1. int months
)

Adds the specified number of months to the current DateTime.

Args: months (int): The number of months to add.

Returns: DateTime: A new DateTime object with the added months. Audited: 2026-06-12 11:26 EDT

Implementation

@useResult
DateTime addMonths(int months) {
  if (months == 0) {
    return this;
  }

  return Jiffy.parseFromDateTime(this).add(months: months).dateTime;
}