subtractMonths method

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

Subtracts the specified number of months from the current DateTime.

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

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

Implementation

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

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