Back to articles
MultiCarbon: Native Jalali & Hijri Calendar Support for PHP Carbon

MultiCarbon: Native Jalali & Hijri Calendar Support for PHP Carbon

via Dev.tohamed pakdaman

If you've ever worked on a project targeting users in Iran, Afghanistan, or Arabic-speaking countries, you know the pain of converting dates between Jalali (Solar Hijri), Hijri (Islamic Lunar), and Gregorian calendars. I built MultiCarbon to solve this once and for all — not as a wrapper, but as a direct extension of nesbot/carbon . Every Carbon method you already know works seamlessly in any calendar mode. ## Install composer require hpakdaman/multicarbon Requires PHP 8.1+ and Carbon 3. The Basics — One Timestamp, Three Calendars The core idea is simple: the underlying timestamp never changes. You just switch the presentation layer. use MultiCarbon\MultiCarbon; $date = new MultiCarbon('2025-03-21'); echo $date->jalali()->format('l j F Y'); // جمعه 1 فروردین 1404 echo $date->hijri()->format('l j F Y'); // الجمعة 21 رمضان 1446 echo $date->gregorian()->format('l j F Y'); // Friday 21 March 2025 That's it. Same object, three calendars, fully fluent. Create Dates Directly in Any Calendar N

Continue reading on Dev.to

Opens in a new tab

Read Full Article
4 views

Related Articles