Methods
date->toString()
Return the default string representation of a NepaliDate instance in standard year, month, and day format.
The toString method converts the NepaliDate instance into a standard readable date string formatted as year, month, and day separated by forward slashes. It provides a simple default serialization format suitable for logs and quick display.
Import
use NepaliDateLibrary\NepaliDate;Signature
public function toString(): string;Parameters
- None.
Return Value
- Type:
string - Format:
YYYY/M/D(e.g."2081/7/15").
Examples
use NepaliDateLibrary\NepaliDate;
$date = new NepaliDate('2081-07-15');
echo $date->toString() . PHP_EOL; // "2081/7/15"
// String casting triggers __toString()
echo (string) $date; // "2081/7/15"Related
date->format(): Custom token formatting.date->clone(): Duplicate an instance.
Advertisement
date->format()
Format a NepaliDate instance into a custom string using token patterns for English and Nepali output.
date->clone()
Create an independent deep clone of an existing NepaliDate instance.