PHPackages                             danialzash/laravel-jalali - 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. danialzash/laravel-jalali

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

danialzash/laravel-jalali
=========================

Laravel helpers for Jalali (Shamsi) date formatting

v0.1.0(4mo ago)01MITPHPPHP ^8.1CI passing

Since Jan 8Pushed 4mo agoCompare

[ Source](https://github.com/danialzash/laravel-jalali)[ Packagist](https://packagist.org/packages/danialzash/laravel-jalali)[ RSS](/packages/danialzash-laravel-jalali/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Laravel Jalali
==============

[](#laravel-jalali)

[![Latest Version on Packagist](https://camo.githubusercontent.com/424ab756f473505b2b9eaba36133a9e2804be0bb631ee62e1e1093abca634b47/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64616e69616c7a6173682f6c61726176656c2d6a616c616c692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danialzash/laravel-jalali)[![License](https://camo.githubusercontent.com/5d9016549f8f765e6d68351290db33474ae109b0cd6b369557e0fa9e2515bcb7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64616e69616c7a6173682f6c61726176656c2d6a616c616c692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danialzash/laravel-jalali)

A Laravel package that provides seamless Jalali (Shamsi/Persian) date formatting with Carbon integration.

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10, 11, or 12

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

[](#installation)

Install the package via Composer:

```
composer require danialzash/laravel-jalali
```

The package will auto-register its service provider and facade.

### Publish Configuration (Optional)

[](#publish-configuration-optional)

```
php artisan vendor:publish --tag=jalali-config
```

This will create a `config/jalali.php` file where you can set the default date format:

```
return [
    'default_format' => 'datetime', // Options: 'datetime', 'date', 'time', or custom format
];
```

Usage
-----

[](#usage)

### Using the Helper Function

[](#using-the-helper-function)

The simplest way to convert dates to Jalali:

```
// Current date/time in Jalali
jalali();

// Convert a specific date
jalali('2024-03-20');

// With custom format
jalali(now(), 'Y/m/d');

// From a Carbon instance
jalali($user->created_at, 'l j F Y');
```

### Using the Facade

[](#using-the-facade)

```
use Danialzash\LaravelJalali\Facades\Jalali;

// Get a Jalalian instance
$jalaliDate = Jalali::from(now());

// Format directly
$formatted = Jalali::format(now(), 'Y-m-d H:i:s');
```

### Using Carbon Macros

[](#using-carbon-macros)

The package adds two macros to Laravel's Carbon class:

```
use Illuminate\Support\Carbon;

// Get a Jalalian instance from Carbon
$jalali = Carbon::now()->toJalali();

// Get a formatted Jalali string directly
$dateString = Carbon::now()->toJalaliString('Y/m/d');

// Works with any Carbon instance
$user->created_at->toJalaliString(); // e.g., "1402/12/30 14:30:00"
```

### Working with Jalalian

[](#working-with-jalalian)

The `toJalali()` method returns a `Morilog\Jalali\Jalalian` instance, giving you access to all its methods:

```
$jalali = now()->toJalali();

$jalali->getYear();       // 1402
$jalali->getMonth();      // 12
$jalali->getDay();        // 30
$jalali->format('l j F'); // پنجشنبه 30 اسفند
$jalali->ago();           // 2 ساعت پیش
```

Format Characters
-----------------

[](#format-characters)

Common format characters (from `morilog/jalali`):

CharacterDescriptionExample`Y`Full year1402`y`Two-digit year02`m`Month (zero-padded)01-12`n`Month1-12`d`Day (zero-padded)01-31`j`Day1-31`H`Hour (24-hour, zero-padded)00-23`i`Minutes (zero-padded)00-59`s`Seconds (zero-padded)00-59`F`Full month nameفروردین`l`Full day nameشنبه`D`Short day nameشExamples
--------

[](#examples)

```
// In a Blade template
تاریخ ثبت‌نام: {{ $user->created_at->toJalaliString('Y/m/d') }}

// In a controller
public function show(User $user)
{
    return [
        'name' => $user->name,
        'joined' => jalali($user->created_at, 'j F Y'),
    ];
}

// With Eloquent
$posts = Post::latest()->get()->map(fn ($post) => [
    'title' => $post->title,
    'date' => $post->created_at->toJalaliString('Y/m/d'),
]);
```

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [Danial Zash](https://github.com/danialzash)
- [morilog/jalali](https://github.com/morilog/jalali) - The underlying Jalali date library

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance77

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c074a8523f1d40ffb6037b8d6c6d642307b83d804acfb05b312b7fb65b17bcf?d=identicon)[danialzash](/maintainers/danialzash)

---

Top Contributors

[![danialzash](https://avatars.githubusercontent.com/u/40217623?v=4)](https://github.com/danialzash "danialzash (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/danialzash-laravel-jalali/health.svg)

```
[![Health](https://phpackages.com/badges/danialzash-laravel-jalali/health.svg)](https://phpackages.com/packages/danialzash-laravel-jalali)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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