Methods
date->getEnglishDate()
Retrieve the equivalent Gregorian date as a native JavaScript Date object.
The getEnglishDate method returns the native PHP DateTimeImmutable object corresponding to the current NepaliDate instance. This allows seamless integration with third party libraries, databases, and standard PHP APIs that expect a native Gregorian datetime object.
Import
use NepaliDateLibrary\NepaliDate;Signature
public function getEnglishDate(): DateTimeImmutable;Parameters
- None.
Return Value
- Type:
DateTimeImmutable - Description: Native PHP DateTimeImmutable object in UTC matching the current Bikram Sambat date.
Example
use NepaliDateLibrary\NepaliDate;
$nd = new NepaliDate('2081-07-15');
$adDate = $nd->getEnglishDate();
echo get_class($adDate) . PHP_EOL; // "DateTimeImmutable"
echo $adDate->format('Y-m-d'); // "2024-10-31"Related
BStoAD(): String based date conversion.NepaliDate Constructor: Construct from DateTimeInterface.
Advertisement
date->getTime()
Retrieve the numeric timestamp in milliseconds since the Unix epoch.
date->set()
Set year, month, and day coordinates simultaneously on a NepaliDate instance.