PHPackages                             kindy/hijridate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. kindy/hijridate

ActiveLibrary

kindy/hijridate
===============

Package for Hijri date conversion and manipulation in PHP

V1.1.1(1y ago)31.2k↓100%MITPHP

Since Dec 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mrkindy/hijridate)[ Packagist](https://packagist.org/packages/kindy/hijridate)[ Docs](https://github.com/mrkindy/hijridate)[ RSS](/packages/kindy-hijridate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Kindy Hijri Date Package
========================

[](#kindy-hijri-date-package)

This PHP package provides functionalities for handling Hijri (Islamic) dates, including conversion, formatting, and integration with Gregorian calendars. The package features enhanced modularity and functionality, making it highly useful for PHP developers requiring Hijri date processing.

Features
--------

[](#features)

- **Hijri Calendar Compliance**:

    - Fully adheres to the astronomical conventions used by astronomers and matches the standards in Microsoft products and the *Calendar of the Centuries* by Dr. Saleh Al-Ojairi.
    - Includes full support for the Umm Al-Qura calendar.
- **Custom Calendar Adjustments**:

    - Supports saving and restoring calendar adjustments, allowing customization to reflect specific events like Ramadan and Eid declarations.
- **Hijri and Gregorian Integration**:

    - Combines both calendars seamlessly in a single programming operation.
    - Uses `date`-style format characters prefixed with `_` for Hijri date formatting.
- **Language Support**:

    - Includes 20 global languages for Hijri month names.
    - Displays Gregorian dates in Arabic when the language is set to Arabic.
- **Integration with PHP `DateTime`**:

    - Fully compatible with PHP's `DateTime` class, with additional methods for Hijri-specific functionalities.
    - Automatically handles timezone differences.

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require kindy/hijridate
```

Namespace and Class Structure
-----------------------------

[](#namespace-and-class-structure)

The package follows a modular approach with the following structure:

- **Namespace**: `Kindy\HijriDate`
- **Classes**:
    - `HijriDateTime`: Handles Hijri date and time functionalities.
    - `Calendar`: Provides core conversion and calculation utilities.
    - `CalendarAdjustment`: Enables custom calendar adjustments.

Usage
-----

[](#usage)

### Basic Example: Display Current Hijri Date

[](#basic-example-display-current-hijri-date)

### HijriDateTime Class

[](#hijridatetime-class)

#### Constructor

[](#constructor)

```
public HijriDateTime::__construct(
    string $time = "now",
    DateTimeZone $timezone = null,
    string $langcode = null,
    Kindy\HijriDate\Calendar $calendar = null
)
```

- `time` : String in a format accepted by strtotime() default is 'now'
- `$timezone` : Time zone of the time default is ini timezone
- `langcode`: Default language (`ar` for Arabic, others default to English).
- `calendar`: Calendar object which used for calendar converting, if not set the class will create Calendar object with default settings.

#### Format Hijri Dates

[](#format-hijri-dates)

```
public function format(string $format): string
```

#### Format Hijri Dates

[](#format-hijri-dates-1)

```
public function format(string $format): string
```

#### Hijri Dates Static Method

[](#hijri-dates-static-method)

```
HijriDateTime::Date('_Y-_m-_d','2024-12-3');
```

#### Hijri Dates objet by new instance

[](#hijri-dates-objet-by-new-instance)

```
use Kindy\HijriDate\HijriDateTime;

echo (new HijriDateTime())->format('_j _M _Yهـ');
// Output: 8 شعبان 1436هـ
```

#### Hijri and Gregorian Dates Together

[](#hijri-and-gregorian-dates-together)

```
echo (new HijriDateTime())->format('D _j _M _Yهـ (j-m-Yم)');
// Output: الثلاثاء 8 شعبان 1436هـ (26-05-2015م)
```

#### Convert Specific Gregorian Date to Hijri

[](#convert-specific-gregorian-date-to-hijri)

```
echo (new HijriDateTime("2015-5-22"))->format('D _j _M _Yهـ (j-m-Yم)');
// Output: الجمعة 4 شعبان 1436هـ (22-05-2015م)
```

#### Create Hijri Date Object from Hijri Date

[](#create-hijri-date-object-from-hijri-date)

```
use Kindy\HijriDate\HijriDateTime;

$hijirDate = HijriDateTime::createFromHijri(1436, 9, 1);
echo $hijirDate->format('D _j _M _Yهـ (j-m-Yم)');
// Output: الخميس 1 رمضان 1436هـ (18-06-2015م)
```

### Formatting Time and Date in the Hijri Calendar

[](#formatting-time-and-date-in-the-hijri-calendar)

The function formats time and date using specific characters, with no differences in parameters but varying outputs depending on the characters used. Below is a table explaining the functionality of each character:

CharacterDescriptionExample Output**\_j**Day without leading zeros1-30**\_d**Day with leading zeros01-30**S**Ordinal suffix (English only, new in version 2.3)st-nd-th**\_z**Day of the year (starting from zero)0-354**\_M, \_F**Month nameمحرم, صفر, ...**\_m**Month number with leading zeros01-12**\_n**Month number without leading zeros1-12**\_t**Number of days in the month29-30**\_L**Leap year indicator (1 = Leap Year, 0 = Not Leap Year)1 or 0**\_Y**Full year number1436**\_y**Two-digit year36### Adjusted Gregorian Date Formatting in Arabic Language

[](#adjusted-gregorian-date-formatting-in-arabic-language)

When selecting the Arabic language, some Gregorian date formatting characters are adjusted as follows:

CharacterDescriptionExample Output**l, D**Day of the week nameالسبت, الأحد...**F**Month names in Syriac termsكانون الثاني, شباط...**M**Month names in English termsيناير, فبراير...**a**AM/PM in Arabic symbolsص-م**A**AM/PM in Arabic full textصباحا - مساءExtended Features
-----------------

[](#extended-features)

### Additional Methods

[](#additional-methods)

The `HijriDateTime` class includes custom methods for Hijri-specific functionalities:

- **`HijriDateTime::createFromHijri(year, month, day)`**: Creates a `HijriDateTime` object from a specific Hijri date.
- **`HijriDateTime::setDateHijri(year, month, day)`**: Sets the Hijri date for an existing `HijriDateTime` object.

### Calendar Class

[](#calendar-class)

The `Calendar` class provides low-level utilities such as:

- Conversion between Julian and Hijri calendars.
- Determining leap years.
- Validating Hijri dates.

### Example: Days in Hijri Month

[](#example-days-in-hijri-month)

```
use Kindy\HijriDate\Calendar;

echo (new Calendar())->days_in_month(9, 1436);
// Output: 29
```

Using the Package with Legacy Code
----------------------------------

[](#using-the-package-with-legacy-code)

If you want to use this library without changing existing `DateTime`-dependent code, alias `HijriDateTime` as `DateTime`:

```
use Kindy\HijriDate\HijriDateTime as DateTime;
```

Alternatively, create a custom `hdate()` function to replace PHP's `date()`:

```
function hdate($format, $timestamp = null)
{
    if (!isset($timestamp)) {
        $timestamp = time();
    }
    $d = new HijriDateTime('@' . $timestamp);
    return $d->format($format);
}
```

Contributing
------------

[](#contributing)

Your contribution is welcome

Credits
-------

[](#credits)

- [Ibrahim Abotaleb](https://github.com/mrkindy)
- [Saeed Hubaishan](https://github.com/hubaishan)

License
-------

[](#license)

This package is licensed under [GPL-2 License](LICENSE).

---

**Note**: For detailed documentation and examples, refer to the official API or the `examples.php` file in the repository.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance41

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

521d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d5fd85e534ea2f57176af791158952e47f137990cf3a4d1c072a5feb7aa24dbc?d=identicon)[mrkindy](/maintainers/mrkindy)

---

Top Contributors

[![mrkindy](https://avatars.githubusercontent.com/u/744360?v=4)](https://github.com/mrkindy "mrkindy (7 commits)")

---

Tags

hijridate-conversionhijri-datelaravel-hijri-datePHP Hijri DateDate Conversion To Hijri

### Embed Badge

![Health badge](/badges/kindy-hijridate/health.svg)

```
[![Health](https://phpackages.com/badges/kindy-hijridate/health.svg)](https://phpackages.com/packages/kindy-hijridate)
```

###  Alternatives

[alkoumi/laravel-hijri-date

Laravel package to Convert laravel date to our Amazing 💝 Hjri date {ummul qura and vice versa} . to look like \[ الخميس ، ٢٢ ربيع الآخر ، ١٤٤١ - ٠٧:٤٩ مساءً\]

109166.2k2](/packages/alkoumi-laravel-hijri-date)[fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

36473.2k8](/packages/fisharebest-ext-calendar)[arutil/ar-php

Arabic php utilities from Khaled Al-Sham'aa's library http://ar-php.org/

1735.1k](/packages/arutil-ar-php)[pharaonic/laravel-hijri

Laravel - Hijri DateTime (Islamic)

1331.0k](/packages/pharaonic-laravel-hijri)[mohamedsabil83/laravel-hijrian

Hijri-Gregorian date converter for Laravel

1220.0k](/packages/mohamedsabil83-laravel-hijrian)[mohamedsabil83/filament-hijri-picker

A Hijri date time picker component for Filament

224.4k](/packages/mohamedsabil83-filament-hijri-picker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
