You can create a Jalalian instance using the constructor by providing year, month, day, and optional time components. Alternatively, use static factory methods to create instances from existing date objects or timestamps.
Factory Methods:
now(?\DateTimeZone $timeZone): Returns a Jalalian instance representing the current time.fromCarbon(Carbon $carbon): Creates a Jalalian instance from a Carbon object.fromFormat(string $format, string $timestamp, ?\DateTimeZone $timeZone): Creates an instance by parsing a timestamp string with a specific format.forge($timestamp, ?\DateTimeZone $timeZone): A versatile method that accepts a timestamp (numeric) or a \DateTimeInterface string.fromDateTime(\DateTimeInterface|string $dateTime, ?\DateTimeZone $timeZone): Similar to forge, handles numeric timestamps or date strings.
use Morilog//Jalali\Jalalian;
// Using constructor
$date = new Jalalian(1402, 5, 10, 12, 30, 0);
// Using factory methods
$now = Jalalian::now();
$fromCarbon = Jalalian::fromCarbon($carbonInstance);
$fromFormat = Jalalian::fromFormat('Y-m-d', '1402-05-10');
$forged = Jalalian::forge('2023-07-31');