Hijri

Hijri

Hijri DateTime (Islamic) for Laravel.

Moamen Eltouny (Raggi)
PHP Version : >= 7.2 Laravel Version : >= 6.0 License Support
Source Packagist Version Packagist Downloads

Install

Install the latest version using Composer

composer require pharaonic/laravel-hijri

Depends on : Carbon, Hijri

Usage

Getting Hijri

This is how to get Hijri/Gregorian DateTime

$dt = Carbon::now(); // OR $model->created_at;

echo $dt->isoFormat('LLLL');                // Tuesday, May 25, 2021 7:00 PM
echo $dt->toHijri()->isoFormat('LLLL');     // Tuesday, Shawwal 13, 1442 7:00 PM

echo $dt->format('r');                      // Tue, 25 May 2021 07:00:00 +0000
echo $dt->toHijri()->format('r');           // Tue, 13 Shawwal 1442 07:00:00 +0000

Localization

Using Hijri with multiple languages.

Carbon::setLocale('ar');
echo $dt->toHijri()->isoFormat('LLLL');    // الثلاثاء 13 شوّال 1442 07:00

// OR [Inline]
echo $dt->locale('ar')->toHijri()->isoFormat('LLLL');