Nepali DateNepali DateBikram Sambat Date Engine
Methods

Packagistdate->addMonths()

Add or subtract months to a NepaliDate instance while adjusting for variable month lengths.

The addMonths method advances or rewinds the current NepaliDate instance by a specified number of months. If the current day of the month exceeds the total days available in the destination month, the method automatically clamps the day to the final valid day of that month to ensure calendar consistency.


Import

use NepaliDateLibrary\NepaliDate;

Signature

public function addMonths(int $months): self;

Parameters

ParameterTypeRequiredDescription
$monthsintYesPositive or negative integer of months to add.

Return Value

  • Type: NepaliDate
  • Description: Returns $this after mutation.

Example

use NepaliDateLibrary\NepaliDate;

$date = new NepaliDate('2081-01-15');
$date->addMonths(6);
echo $date->format('YYYY-MM-DD'); // "2081-07-15"

Advertisement

On this page