Pharaonic
Loading...

Getting Started

Hijri

# Why Hijri?

Hijri is a package that helps you to convert the Gregorian date to a Hijri date, and it's available in multiple languages.
For example : Convert Tuesday, May 25, 2021 7:00 PM To Tuesday, Shawwal 13, 1442 7:00 PM.

This package depends on Carbon.

# Installation

Install the latest version using Composer.

1composer require pharaonic/laravel-hijri

# Convert Gregorian to Hijri

This is how to get Hijri/Gregorian DateTime.

1$dt = Carbon::now();
2 
3echo $dt->isoFormat('LLLL'); // Tuesday, May 25, 2021 7:00 PM
4echo $dt->toHijri()->isoFormat('LLLL'); // Tuesday, Shawwal 13, 1442 7:00 PM
5 
6echo $dt->format('r'); // Tue, 25 May 2021 07:00:00 +0000
7echo $dt->toHijri()->format('r'); // Tue, 13 Shawwal 1442 07:00:00 +0000

# Localization

Using Hijri with multiple languages through 2 ways [ global, inline ] .

You can use a specific language as you want, just you need to change ar to the language that you need.

1$dt = Carbon::now();
2 
3// Global
4Carbon::setLocale('ar');
5echo $dt->toHijri()->isoFormat('LLLL'); // الثلاثاء 13 شوّال 1442 07:00
6 
7// Inline
8echo $dt->toHijri()->locale('ar')->isoFormat('LLLL');

# Contributors

MoamenEltouny
12 Contributions