
How to Convert Between Gregorian and Hijri Dates in PHP
Convert Gregorian dates to Hijri and back in PHP with ext-intl's Umm al-Qura calendar, and learn when a tabular Hijri calendar is a day off.
Turn any Carbon date into "1 Ramadan 1445" with one toHijri() call, and convert it back just as easily.
Each line is released for the versions in its row, read from that release's composer.json. Pick the line that matches your project; a combination not listed isn't supported. Find the right line of every package for your project.
| Line | Latest release | PHP | Status | Docs |
|---|---|---|---|---|
| v8.5.x | v8.5.6 Oct 8, 2026 | 8.5 | Current | Docs: Read the v8.5.x docs |
| v8.4.x | v8.4.6 Oct 8, 2026 | 8.4 | Maintained | Docs: Read the v8.4.x docs |
| v8.3.x | v8.3.6 Oct 8, 2026 | 8.3 | Maintained | Docs: Read the v8.3.x docs |
| v8.2.x | v8.2.6 Oct 8, 2026 | 8.2 | Maintained | Docs: Read the v8.2.x docs |
| v8.1.x | v8.1.5 Oct 8, 2026 | 8.1 | MaintainedPHP 8.1 no longer gets security fixes | Docs: Read the v8.1.x docs |
| v8.0.x | v8.0.6 Oct 8, 2026 | 8.0 | MaintainedPHP 8.0 no longer gets security fixes | Docs: Read the v8.0.x docs |
From the package's releases and its GitHub Actions. A passing run means the test suite passed on develop, on every PHP version it supports; it isn't a security review, and each release line has its own runs on GitHub. Checked hourly.
Convert a Gregorian date to Hijri and back again.
1use Carbon\Carbon; 2use Pharaonic\Hijri\HijriCarbon; 3 4Carbon::mixin(HijriCarbon::class); 5 6Carbon::parse('2024-03-11')->toHijri()->isoFormat('dddd D MMMM YYYY'); 7// "Monday 1 Ramadan 1445" 8 9Carbon::fromHijri(1445, 10, 1)->toDateString();10// "2024-04-10"Register one Carbon mixin and every date in your app speaks Hijri.
Call toHijri() on any Carbon date, or Hijri::parse() on any string Carbon understands.
Build a Gregorian Carbon date from Hijri parts with Carbon::fromHijri(1445, 9, 1).
Parse YYYY-MM-DD Hijri strings with an optional time using Carbon::parseHijri().
Month names switch between Arabic and transliterated English based on the Carbon locale.
Shift conversions by whole days to match local moon sighting, globally or per call.
HijriCalendar checks leap years, month lengths, and whether a Hijri date exists.
Practical guides that use PHP Hijri, or solve the problem it was built for.

Convert Gregorian dates to Hijri and back in PHP with ext-intl's Umm al-Qura calendar, and learn when a tabular Hijri calendar is a day off.
Quick answers about installing and using Hijri.
Hijri (Islamic) date support for PHP built on Carbon. Convert Gregorian dates to Hijri and back, parse Hijri strings, and format month names in Arabic or English. It's a free, open-source PHP package by Pharaonic.
Run composer require pharaonic/php-hijri in your project's root directory.
The latest release requires PHP 8.5.
Yes. Hijri is open source under the MIT license, so you can use it in personal and commercial projects.
It uses the tabular (arithmetic) Islamic calendar, the same 30-year cycle used by most software. Real-world dates can differ by a day or two from local moon sighting, so the package lets you shift results with a day adjustment.
Set an Arabic locale, either globally with Carbon::setLocale('ar') or per date with ->locale('ar'). Any ar locale uses the Arabic month names; every other locale uses the English transliteration.
No. The Julian Day math is done in plain PHP, so ext-calendar isn't required.
Read the Hijri documentation for setup, configuration, and usage examples.
Open an issue or a pull request on GitHub, or ask in the Pharaonic Discord.
Read the full documentation for installation, the day adjustment, Gregorian to Hijri and Hijri to Gregorian conversion, localized formatting, calendar validation, and real-world examples.