Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jalali Laravel Package

morilog/jalali

morilog/jalali provides a fast, human-friendly Jalali (Persian) calendar API for PHP/Laravel. Convert and format dates, manipulate and compare date/times via the immutable Jalalian class, with helpers like jdate(), Carbon support, and “ago” relative output.

View on GitHub
Deep Wiki
Context7

This Package helps developers to easily work with Jalali (Shamsi or Iranian) dates in php appliations, based on Jalali (Shamsi) DateTime class.

Frequently asked questions about Jalali
How do I install morilog/jalali in a Laravel project?
Run `composer require morilog/jalali:3.*` in your project directory. The package requires PHP 7.1+ and integrates directly with Laravel’s Carbon and Eloquent. No additional Laravel service provider setup is needed.
Does this package work with Laravel’s Carbon?
Yes, the package provides `Jalalian::fromCarbon()` for conversions and mirrors Carbon’s API where possible. You can also use Carbon macros to alias Jalali methods for seamless integration.
What’s the difference between `jdate()` and `Jalalian::forge()`?
`jdate()` is a helper function for quick instantiation (e.g., `jdate('last sunday')`), while `Jalalian::forge()` offers more explicit control. Both return immutable `Jalalian` objects for date manipulation.
How do I format Jalali dates in Blade templates?
Use the `format()` method directly: `{{ jdate()->format('%d %B %Y') }}` outputs Persian dates like `23 اسفند 1402`. For reusable formatting, create a Blade directive or Carbon macro.
Is this package compatible with PHP 8.1+ strict typing?
Yes, version 3.5.0 includes explicit nullable type hints (e.g., `DateTimeZone|null`) to avoid `TypeError` in strict mode. Audit your code for implicit null assumptions if upgrading from older versions.
Can I store Jalali dates in the database?
No, store Gregorian timestamps in the database and convert to Jalali in the presentation layer using Eloquent accessors/mutators or global scopes. The package doesn’t modify database storage strategies.
How do I handle timezone differences with Jalali dates?
Pass a `DateTimeZone` to `Jalalian::now()` or `fromCarbon()`. The package respects timezone settings but requires explicit handling for null timezones in strict PHP environments.
Are there alternatives to morilog/jalali for Persian dates?
Other options include `jalaali/jalaali-js` (JavaScript-focused) or custom implementations, but morilog/jalali is the most mature PHP/Laravel solution with Carbon integration and active maintenance.
How do I test Jalali date conversions in Laravel?
Use PHPUnit to test `Jalalian` methods with edge cases (e.g., invalid dates, timezones). Validate Carbon interoperability by comparing outputs with `Carbon::parse()` and `Jalalian::fromCarbon()`.
Does this package support relative time formatting (e.g., 'ago')?
Yes, use the `ago()` method: `jdate('now - 10 minutes')->ago()` returns `10 دقیقه پیش`. This works for both past and future dates with human-readable Persian output.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
graham-campbell/flysystem
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi