Search by

fisharebest / calendar

fisharebest

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian, Persian (Jalali) and Swedish calendars.

dev-main 2026-11-19 15:29 UTC

This package is auto-updated.

Last update: 2026-11-19 15:29:45 UTC


README

PHPCS PHPStan Psalm PHPUnit Test coverage Infection Licence

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.