Looking to hire Laravel developers? Try LaraJobs

laravel-hijri-dates maintained by adaa

Description
Hijri (Islamic) date support for Laravel, using geniusTS/hijri-dates.
Author
Last update
2026/09/05 14:21 (dev-main)
License
Links
Downloads
16

Comments
comments powered by Disqus

Hijri Dates for Laravel

Latest Stable Version Total Downloads License

Laravel package for Hijri (Islamic calendar) date conversion, built on top of geniusts/hijri-dates.

Requirements

Laravel PHP Package
5 7.0+ v1.0
6–9 7.2+ v1.1
10–13 8.1+ v1.2

Installation

composer require adaa/laravel-hijri-dates

Laravel 5.5+ auto-discovers the service provider. For older versions, add it manually in config/app.php:

'providers' => [
    // ...
    Adaa\LaravelHijri\HijriDatesServiceProvider::class,
],

Publishing

# Config file → config/hijri-dates.php
php artisan vendor:publish --provider="Adaa\LaravelHijri\HijriDatesServiceProvider" --tag=config

# Translation files → lang/vendor/hijri-dates/
php artisan vendor:publish --provider="Adaa\LaravelHijri\HijriDatesServiceProvider" --tag=translation

Usage

use GeniusTS\HijriDate\Date;
use GeniusTS\HijriDate\Hijri;

// Current Hijri date
$hijri = Date::now();
echo $hijri;                           // e.g. 1448-03-01

// Conversion: Gregorian → Hijri
$hijri = Hijri::convertToHijri('2026-09-05');
echo $hijri->format('l j F o');        // e.g. Saturday 23 Rabi' al-awwal 1448

// Conversion: Hijri → Gregorian
$gregorian = Hijri::convertToGregorian(23, 3, 1448);
echo $gregorian->format('Y-m-d');      // e.g. 2026-09-05

// Arabic day/month names
echo $hijri->format('l d F o');        // uses Arabic month names by default
echo $hijri->format('l d F o', Date::INDIAN_NUMBERS); // with Indian numerals

// Set adjustment (±1 day fine-tuning)
Hijri::setDefaultAdjustment(1);

Configuration

// config/hijri-dates.php
return [
    // Adjustment days (±1)
    'adjustment' => 0,

    // Translation class (Laravel translations or custom)
    'translation' => \Adaa\LaravelHijri\Translations\Laravel::class,

    // Default date/time format
    'toStringFormat' => 'Y-m-d H:i:s',

    // Numeric system: Date::ARABIC_NUMBERS, Date::INDIAN_NUMBERS, Date::PERSIAN_NUMBERS
    'numeric_system' => \GeniusTS\HijriDate\Date::ARABIC_NUMBERS,
];

Translations

Package ships with Arabic and English translation files. To add a new locale:

  1. Create resources/lang/vendor/hijri-dates/<locale>/dates.php.
  2. Return an array with keys: days, short_days, months, periods (same structure as the package files).

To override the default locale files in your app, publish them and edit the copies under lang/vendor/hijri-dates/.

License

This package is free software distributed under the terms of the MIT license.


Originally based on GeniusTS/hijri-dates.