Methods
date->setYear()
Set the Bikram Sambat year on a NepaliDate instance within the supported calendar range.
The setYear method updates the four digit Bikram Sambat year on the current NepaliDate instance and adjusts the timestamp accordingly. The target year must fall within the supported range between 1976 and 2100 BS.
Import
use NepaliDateLibrary\NepaliDate;Signature
public function setYear(int $year): void;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
$year | int | Yes | Target Bikram Sambat year between 1976 and 2100. |
Return Value
- Type:
void - Note: Mutates the current instance in place.
Example
use NepaliDateLibrary\NepaliDate;
$date = new NepaliDate('2080-07-15');
$date->setYear(2081);
echo $date->format('YYYY-MM-DD'); // "2081-07-15"Related
date->getYear(): Retrieve current year.date->addYears(): Add or subtract years.
Advertisement
date->set()
Set year, month, and day coordinates simultaneously on a NepaliDate instance.
date->setMonth()
Set the Bikram Sambat month index on a NepaliDate instance with automatic day clamping.