PHPackages                             hanifhefaz/dcter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hanifhefaz/dcter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hanifhefaz/dcter
================

A composer package used to convert Jalali, Hijri, Gregorian and Julian dates to each others. Plus some extra utilities and helpers.

v2.0.1(8mo ago)342.0k4[1 issues](https://github.com/hanifhefaz/dcter/issues)MITPHPCI passing

Since Apr 7Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/hanifhefaz/dcter)[ Packagist](https://packagist.org/packages/hanifhefaz/dcter)[ GitHub Sponsors](https://github.com/hanifhefaz)[ RSS](/packages/hanifhefaz-dcter/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (9)Dependencies (2)Versions (11)Used By (0)

Dcter 📆 Dates Converter
=======================

[](#dcter-calendar-dates-converter)

[![](images/banner.png)](images/banner.png)

[![Latest Stable Version](https://camo.githubusercontent.com/76a3c901fd7e6f55ae6341e0321558949a08383286d3db3eb4cb2b13e4e3f86b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68616e6966686566617a2f64637465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hanifhefaz/dcter)[![Total Downloads](https://camo.githubusercontent.com/f9d65501bcef70f5651ace57f9e2bc6b1d91ffe55f10b83f6ab65b3ffa30d993/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68616e6966686566617a2f64637465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hanifhefaz/dcter)[![Tests](https://github.com/hanifhefaz/dcter/actions/workflows/tests.yml/badge.svg)](https://github.com/hanifhefaz/dcter/actions/workflows/tests.yml)[![GitHub Issues](https://camo.githubusercontent.com/5702784a63420cc7fb5934edee080f1919c6acd85e43f3597312aa07f19cfddf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f68616e6966686566617a2f64637465722e737667)](https://github.com/hanifhefaz/dcter/issues)

A Laravel-compatible Composer package that converts dates between **Hijri (Qamari)**, **Jalali (Shamsi/Persian)**, **Gregorian**, and **Julian** calendars.
It also includes powerful date utilities, localization, numeral conversions, and Artisan command support.

Please consider a ⭐ if this package helps you.

---

🧩 Features
----------

[](#-features)

✅ Convert between **Hijri**, **Jalali**, **Gregorian**, and **Julian**
✅ Get **localized month and weekday names** (English, Arabic, Persian)
✅ Flexible **date formatting**
✅ Compare and get **differences in days**
✅ Get **today’s date** in any calendar
✅ Add or subtract days in any calendar
✅ Convert **Arabic and English numerals**
✅ Validate dates across calendars
✅ Integrated **Laravel Facade** and **Service Provider**
✅ Artisan command for quick date conversion
✅ **Carbonize** any calendar date

---

🧭 Installation
--------------

[](#-installation)

```
composer require hanifhefaz/dcter
```

For Laravel 8+, it auto-registers via package discovery.
If not, manually add to `config/app.php`:

```
'providers' => [
    HanifHefaz\Dcter\DcterServiceProvider::class,
],

'aliases' => [
    'Dcter' => HanifHefaz\Dcter\Facades\Dcter::class,
],
```

---

🚀 Usage
-------

[](#-usage)

### 1️⃣ Core Conversions

[](#1️⃣-core-conversions)

Dcter includes 8 core conversion methods and 1 Carbonize helper:

MethodDescription`HijriToGregorian($date)`Hijri ➜ Gregorian`GregorianToHijri($date)`Gregorian ➜ Hijri`JulianToHijri($date)`Julian ➜ Hijri`HijriToJulian($date)`Hijri ➜ Julian`GregorianToJalali($date)`Gregorian ➜ Jalali`JalaliToGregorian($date)`Jalali ➜ Gregorian`HijriToJalali($date)`Hijri ➜ Jalali`JalaliToHijri($date)`Jalali ➜ Hijri`Carbonize($date)`Convert any `YYYY-MM-DD` date into a Carbon objectExample:

```
use HanifHefaz\Dcter\Dcter;

$date = "2025-03-01";
echo Dcter::GregorianToHijri($date); // 1446-08-29
```

---

✨ New Feature Set (v2+)
-----------------------

[](#-new-feature-set-v2)

Below are the new features introduced:

---

### 🗓️ 1. Localized Month Names

[](#️-1-localized-month-names)

```
Dcter::getMonthName(3, 'hijri', 'ar'); // ربيع الأول
Dcter::getMonthName(1, 'jalali', 'fa'); // فروردین
```

---

### 📅 2. Weekday Names

[](#-2-weekday-names)

```
Dcter::getWeekdayName('2025-10-08', 'gregorian', 'en'); // Wednesday
Dcter::getWeekdayName('1447-04-15', 'hijri', 'ar'); // الأربعاء
```

---

### 🧾 3. Custom Date Formatting

[](#-3-custom-date-formatting)

```
Dcter::formatDate('1447-04-15', 'hijri', 'd F Y', 'en');
// 15 Rabi' al-thani 1447
```

---

### ⚖️ 4. Date Comparison

[](#️-4-date-comparison)

```
Dcter::compareDates('1447-01-10', '1447-02-01', 'hijri');
// returns -1  (first is earlier)
```

---

### 📆 5. Difference in Days

[](#-5-difference-in-days)

```
Dcter::diffInDays('1447-01-10', '1447-01-20', 'hijri');
// returns 10
```

---

### ⏰ 6. Get Current Date

[](#-6-get-current-date)

```
Dcter::now();           // Gregorian today
Dcter::now('hijri');    // Hijri today
Dcter::now('jalali');   // Jalali today
```

---

### ➕ 7. Add/Subtract Days

[](#-7-addsubtract-days)

```
Dcter::addDays('1447-01-10', 10, 'hijri'); // 1447-01-20
Dcter::subDays('1447-01-10', 5, 'hijri');  // 1447-01-05
```

---

### 🔢 8. Numeral Conversion

[](#-8-numeral-conversion)

```
Dcter::toArabicNumerals('2025-10-08'); // ٢٠٢٥-١٠-٠٨
Dcter::toEnglishNumerals('٢٠٢٥-١٠-٠٨'); // 2025-10-08
```

---

### ✅ 9. Date Validation

[](#-9-date-validation)

```
Dcter::isValidDate('1447-13-01', 'hijri'); // false
```

---

### 🪄 10. Carbon Integration

[](#-10-carbon-integration)

```
$carbon = Dcter::Carbonize('1402-01-25');
echo $carbon->addDays(10); // 1402-02-05 00:00:00
```

---

### 🧩 11. Laravel Facade Usage

[](#-11-laravel-facade-usage)

Once installed, use the Facade directly:

```
use Dcter;

echo Dcter::GregorianToHijri('2025-03-01');
```

---

### 🖥️ 12. Artisan Command

[](#️-12-artisan-command)

A handy console command to convert dates:

```
php artisan dcter:convert 2025-03-01 --from=gregorian --to=hijri
```

Output:

```
Converted: 1446-08-29

```

---

🧪 Tests
-------

[](#-tests)

You can run all tests with:

```
vendor/bin/phpunit
```

Tests are located in `/tests` and cover all core methods.

---

🧰 Configuration (optional)
--------------------------

[](#-configuration-optional)

You may publish the config file (if extended later) using:

```
php artisan vendor:publish --provider="HanifHefaz\Dcter\DcterServiceProvider"
```

---

❤️ Contributions
----------------

[](#️-contributions)

Contributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) guide before submitting a PR.

---

👨‍💻 Contributors
----------------

[](#‍-contributors)

  [![](https://avatars3.githubusercontent.com/hanifhefaz?v=4?s=100)
**Hanif Hefaz**](https://github.com/hanifhefaz/) ---

🏷️ License
----------

[](#️-license)

This package is open-sourced software licensed under the **MIT license**.

---

🌟 Summary
---------

[](#-summary)

CategoryMethodConversionHijriToGregorian, GregorianToHijri, GregorianToJalali, JalaliToGregorian, HijriToJulian, JulianToHijri, HijriToJalali, JalaliToHijriFormatting &amp; LocalizationgetMonthName, getWeekdayName, formatDateComparison &amp; MathcompareDates, diffInDays, addDays, subDaysUtilitiesnow, isValidDate, toArabicNumerals, toEnglishNumerals, CarbonizeLaravel IntegrationFacade, ServiceProvider, Artisan Command

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance65

Regular maintenance activity

Popularity30

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.7% 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 ~101 days

Recently: every ~227 days

Total

10

Last Release

258d ago

Major Versions

1.1.6 → v2.0.02025-10-08

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/41760085?v=4)[Hanif Hefaz](/maintainers/hanifhefaz)[@hanifhefaz](https://github.com/hanifhefaz)

---

Top Contributors

[![hanifhefaz](https://avatars.githubusercontent.com/u/41760085?v=4)](https://github.com/hanifhefaz "hanifhefaz (32 commits)")[![chulbulkhan](https://avatars.githubusercontent.com/u/258164095?v=4)](https://github.com/chulbulkhan "chulbulkhan (19 commits)")

---

Tags

arabic-calendarcalendardatedate-converterdatetimegregorian-calendargregorian-to-jalalihijri-calendarhijri-dates-converterhijri-to-gregorianjalali-calendarjalali-to-gregorianjalali-to-hijripersian-calendarphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hanifhefaz-dcter/health.svg)

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

###  Alternatives

[illuminate/support

The Illuminate Support package.

582110.9M39.8k](/packages/illuminate-support)[craftcms/feed-me

Import content from XML, RSS, CSV or JSON feeds into entries, categories, Craft Commerce products, and more.

293943.4k27](/packages/craftcms-feed-me)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

53675.5k15](/packages/solspace-craft-freeform)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40140.4k2](/packages/erlandmuchasaj-laravel-gzip)[japanese-date/japanese-date

日本の暦、祝日を取り扱うライブラリ

169.9k](/packages/japanese-date-japanese-date)[solspace/craft-calendar

The most powerful event management and calendaring plugin!

1831.6k1](/packages/solspace-craft-calendar)

PHPackages © 2026

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