Methods
date->clone()
Create an independent deep clone of an existing NepaliDate instance.
The clone method creates and returns an independent duplicate of the current NepaliDate instance. Because several library arithmetic and mutation methods alter instances in place, creating a clone allows you to perform calculations without modifying the original date object.
Import
use NepaliDateLibrary\NepaliDate;Signature
public function clone(): self;Parameters
- None.
Return Value
- Type:
NepaliDate - Description: A new independent
NepaliDateinstance with identical coordinates and timestamp.
Example
use NepaliDateLibrary\NepaliDate;
$original = new NepaliDate('2081-07-15');
$duplicate = $original->clone();
// Mutating duplicate does not affect original
$duplicate->addDays(10);
echo $original->format('YYYY-MM-DD') . PHP_EOL; // "2081-07-15"
echo $duplicate->format('YYYY-MM-DD') . PHP_EOL; // "2081-07-25"Related
NepaliDate Constructor: Copy constructor support.date->addDays(): In-place day arithmetic.
Advertisement
date->toString()
Return the default string representation of a NepaliDate instance in standard year, month, and day format.
NepaliDate::isValid()
Static validation function to verify whether a given year, month, and day combination forms a valid Bikram Sambat date.