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

by majid
2 years ago
877 Views
Click to rate this post!
[Total: 2 Average: 5]

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:

Click to rate this post!
[Total: 2 Average: 5]
See also  Prediction of Iran's electric power consumption

Leave a Reply

Your email address will not be published. Required fields are marked *