Convert Georgian to Jalali in PHP (include Laravel) | Majid Jalilian Code

by majid
6 months قبل
169 Views

1. Install Easy Jalali Library via Composer:

composer require majidcode/easy-jalali

Note: you can use it in your Laravel project.

2. Add your DateTime to EasyJalali

  • If it’s Georgian use EasyJalali::fromGeorgian('2022-11-02', 'Y-m-d'); to create your date in EasyJalali.
  • If it’s Jalali use EasyJalali::fromJalali('1399-05-21', 'Y-m-d'); to create your date in EasyJalali.
  • Also, you can use carbon to create date in EasyJalali: EasyJalali::fromCarbon(Carbon::now());

3. Convert to your format

  • Use toJalali() or toGeorgian() to convert your date.

4. Get your result in your favourite format.

  • You can use toFormat('Y/m/d'); to get your result.

 

Example of use in the Laravel 8.0:

Leave a Reply

Your email address will not be published.