fisharebest / calendar
Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian, Persian (Jalali) and Swedish calendars.
dev-main
2026-11-19 15:29 UTC
Requires
- php: ^8.3
Requires (Dev)
- ext-calendar: *
- fisharebest/badge: ^1.0
- fisharebest/figlet: ^1.0
- infection/infection: ^0.35
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^12.5
- squizlabs/php_codesniffer: ^4.0
- vimeo/psalm: ^7.11
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-19 15:29:45 UTC
README
This package implements the following calendars:
Note, until version 2.6, this package was called fisharebest/ext-calendar
and provided a polyfill for PHP’s ext/calendar extension.
Since version 3.0, it is called fisharebest/calendar, and just provides
calendar and date utilities.
How to use it
composer require fisharebest/calendar
// Create calendars
$calendar = new Fisharebest\Calendar\ArabicCalendar;
$calendar = new Fisharebest\Calendar\FrenchCalendar;
$calendar = new Fisharebest\Calendar\GregorianCalendar;
$calendar = new Fisharebest\Calendar\JewishCalendar;
$calendar = new Fisharebest\Calendar\JulianCalendar;
$calendar = new Fisharebest\Calendar\PersianCalendar;
$calendar = new Fisharebest\Calendar\SwedishCalendar;
// Date conversions
$julian_day = $calendar->ymdToJd(year: $year, month: $month, day: $day);
[$year, $month, $day] = $calendar->jdToYmd(julian_day: $julian_day);
// Information about days, weeks and months
$is_leap_year = $calendar->isLeapYear(year: $year);
$days_in_month = $calendar->daysInMonth(year: $year, month: $month);
$months_in_year = $calendar->monthsInYear(year: $year); // Not all years have 12
$days_in_week = $calendar->daysInWeek(); // Not all calendars have 7
// Which dates are valid?
$jd = $calendar->jdStart();
$jd = $calendar->jdEnd();
Future plans
- Support alternate leap-year schemes for the French calendar (true equinox, Romme, 128-year cycle) as well as the 4-year cycle.
- Support other calendars, such as Ethiopian, Hindu, Chinese, etc.