PHPackages                             condorcet-php/php-calendars - 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. condorcet-php/php-calendars

ActiveLibrary

condorcet-php/php-calendars
===========================

Pure PHP implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a drop-in replacement for the PHP ext/calendar extension.

v3.0.0(1mo ago)09↑2900%GPL-3.0-or-laterPHPPHP &gt;=8.5CI passing

Since Mar 29Pushed 1mo agoCompare

[ Source](https://github.com/julien-boudry/PhpCalendars)[ Packagist](https://packagist.org/packages/condorcet-php/php-calendars)[ Docs](https://github.com/condorcet-php/php-calendars)[ RSS](/packages/condorcet-php-php-calendars/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

PHP Calendars
=============

[](#php-calendars)

Pure PHP implementation of six historical and religious calendars, with an object-oriented API and a drop-in replacement for PHP's `ext/calendar` extension.

This package provides a pure PHP implementation of the [Arabic (Hijri)](https://en.wikipedia.org/wiki/Islamic_calendar), [French Republican](https://en.wikipedia.org/wiki/French_Republican_Calendar), [Gregorian](https://en.wikipedia.org/wiki/Gregorian_calendar), [Julian](https://en.wikipedia.org/wiki/Julian_calendar), [Jewish](https://en.wikipedia.org/wiki/Hebrew_calendar) and [Persian (Jalali)](https://en.wikipedia.org/wiki/Iranian_calendars) calendars, plus a drop-in replacement for PHP‘s [ext/calendar](https://php.net/calendar) extension.

Note

This project is a fork of [fisharebest/ext-calendar](https://github.com/fisharebest/ext-calendar), originally written by Greg Roach for the [webtrees](http://www.webtrees.net) project. It modernises the codebase (PHP 8.5+, strict types, native type declarations) and continues development under the `CondorcetPHP` namespace.

Requirements
============

[](#requirements)

- PHP (64bit) &gt;= 8.5

Installation
============

[](#installation)

```
composer require condorcet-php/php-calendars
```

Object-oriented API
===================

[](#object-oriented-api)

All six calendars implement `CalendarInterface` with the following methods:

MethodDescription`ymdToJd(int $year, int $month, int $day): int`Convert a date to a Julian Day Number`jdToYmd(int $julian_day): array`Convert a Julian Day Number to `[$year, $month, $day]``daysInMonth(int $year, int $month): int`Number of days in a given month`monthsInYear(?int $year = null): int`Number of months in a year (or the maximum if `$year` is `null`)`daysInWeek(): int`Number of days in a week (7 for most calendars, 10 for the French Republican)`isLeapYear(int $year): bool`Whether the given year is a leap year`jdStart(): int`Lowest Julian Day Number accepted by this calendar`jdEnd(): int`Highest Julian Day Number accepted by this calendar`gedcomCalendarEscape(): string`GEDCOM calendar escape sequence### Available calendars

[](#available-calendars)

ClassCalendarMonthsDays/weekJD range`ArabicCalendar`Hijri (Islamic)1271 948 440 – `PHP_INT_MAX``FrenchCalendar`French Republican13102 375 840 – 2 380 687`GregorianCalendar`Gregorian1271 – `PHP_INT_MAX``JewishCalendar`Hebrew12 or 137347 998 – `PHP_INT_MAX``JulianCalendar`Julian1271 – `PHP_INT_MAX``PersianCalendar`Jalali (Iranian)1271 948 321 – `PHP_INT_MAX`The Arabic and Persian calendars are **exclusive to this library** — they are not available in the native `ext/calendar` extension.

### Usage example

[](#usage-example)

```
use CondorcetPHP\PhpCalendars\ArabicCalendar;
use CondorcetPHP\PhpCalendars\FrenchCalendar;
use CondorcetPHP\PhpCalendars\GregorianCalendar;
use CondorcetPHP\PhpCalendars\JewishCalendar;
use CondorcetPHP\PhpCalendars\JulianCalendar;
use CondorcetPHP\PhpCalendars\PersianCalendar;

$calendar = new GregorianCalendar();

// Convert a date to a Julian Day Number and back
$jd = $calendar->ymdToJd(2026, 3, 29);
[$year, $month, $day] = $calendar->jdToYmd($jd);

// Leap year, days in month, months in year
$calendar->isLeapYear(2024);    // true
$calendar->daysInMonth(2024, 2); // 29
$calendar->monthsInYear();       // 12
$calendar->daysInWeek();         // 7

// Valid Julian Day range for this calendar
$calendar->jdStart(); // 1
$calendar->jdEnd();   // PHP_INT_MAX
```

### Jewish calendar extras

[](#jewish-calendar-extras)

`JewishCalendar` provides an additional method to format numbers as Hebrew numerals (UTF-8):

```
$jewish = new JewishCalendar();

// 13 months in a leap year
$jewish->monthsInYear(5784); // 13

// Hebrew numerals — with and without the thousands prefix
$jewish->numberToHebrewNumerals(5781, false); // "תשפ״א"
$jewish->numberToHebrewNumerals(5781, true);  // "ה׳תשפ״א"
```

Drop-in replacement for ext/calendar
====================================

[](#drop-in-replacement-for-extcalendar)

This package also provides shim functions that are automatically registered when the native `ext/calendar` extension is not loaded. All 18 functions and their associated constants are supported:

- [cal\_days\_in\_month()](https://php.net/cal_days_in_month)
- [cal\_from\_jd()](https://php.net/cal_from_jd)
- [cal\_info()](https://php.net/cal_info)
- [cal\_to\_jd()](https://php.net/cal_to_jd)
- [easter\_date()](https://php.net/easter_date)
- [easter\_days()](https://php.net/easter_days)
- [FrenchToJD()](https://php.net/FrenchToJD)
- [GregorianToJD()](https://php.net/GregorianToJD)
- [JDDayOfWeek()](https://php.net/JDDayOfWeek)
- [JDMonthName()](https://php.net/JDMonthName)
- [JDToFrench()](https://php.net/JDToFrench)
- [JDToGregorian()](https://php.net/JDToGregorian)
- [jdtojewish()](https://php.net/jdtojewish)
- [JDToJulian()](https://php.net/JDToJulian)
- [jdtounix()](https://php.net/jdtounix)
- [JewishToJD()](https://php.net/JewishToJD)
- [JulianToJD()](https://php.net/JulianToJD)
- [unixtojd()](https://php.net/unixtojd)

All associated constants are also provided: `CAL_GREGORIAN`, `CAL_JULIAN`, `CAL_JEWISH`, `CAL_FRENCH`, `CAL_NUM_CALS`, `CAL_DOW_DAYNO`, `CAL_DOW_SHORT`, `CAL_DOW_LONG`, `CAL_MONTH_GREGORIAN_SHORT`, `CAL_MONTH_GREGORIAN_LONG`, `CAL_MONTH_JULIAN_SHORT`, `CAL_MONTH_JULIAN_LONG`, `CAL_MONTH_JEWISH`, `CAL_MONTH_FRENCH`, `CAL_EASTER_DEFAULT`, `CAL_EASTER_ROMAN`, `CAL_EASTER_ALWAYS_GREGORIAN`, `CAL_EASTER_ALWAYS_JULIAN`, `CAL_JEWISH_ADD_ALAFIM_GERESH`, `CAL_JEWISH_ADD_ALAFIM`, `CAL_JEWISH_ADD_GERESHAYIM`.

```
// Works whether ext-calendar is installed or not
print_r(cal_info(CAL_GREGORIAN));

$jd = GregorianToJD(3, 29, 2026);
echo JDDayOfWeek($jd, CAL_DOW_LONG); // "Sunday"
echo jdtojewish($jd, true, CAL_JEWISH_ADD_GERESHAYIM);
```

You can also call the static methods on `CondorcetPHP\PhpCalendars\Shim`directly, regardless of whether `ext/calendar` is installed:

```
use CondorcetPHP\PhpCalendars\Shim;

$jd = Shim::gregorianToJd(3, 29, 2026);
echo Shim::jdDayOfWeek($jd, CAL_DOW_LONG);
```

Known restrictions and limitations
==================================

[](#known-restrictions-and-limitations)

- The functions `easter_date()` and `jdtounix()` use PHP's timezone, instead of the operating system's timezone. These may be different.
- Invalid arguments (wrong calendar ID, out-of-range month, etc.) throw a `ValueError`.
- The French Republican calendar only covers years 1–14 (22 Sep 1792 – 31 Dec 1805).

Development and contributions
=============================

[](#development-and-contributions)

See the [CHANGELOG](CHANGELOG.md) for the full release history.

Pull requests are welcome. Please ensure you include unit-tests where applicable.

```
# Run the test suite (Pest)
composer test

# Run the benchmarks (native ext-calendar vs PHP implementation)
composer bench

# Static analysis
composer phpstan

# Code style
composer lint
```

Future plans
============

[](#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.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 69.7% 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

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4020317?v=4)[Julien Boudry](/maintainers/julien-boudry)[@julien-boudry](https://github.com/julien-boudry)

---

Top Contributors

[![fisharebest](https://avatars.githubusercontent.com/u/2306088?v=4)](https://github.com/fisharebest "fisharebest (69 commits)")[![julien-boudry](https://avatars.githubusercontent.com/u/4020317?v=4)](https://github.com/julien-boudry "julien-boudry (29 commits)")[![jon48](https://avatars.githubusercontent.com/u/5150782?v=4)](https://github.com/jon48 "jon48 (1 commits)")

---

Tags

calendarJalaliarabicpersianshamsihijrigregorianfrenchext-calendarjulianjewishhebrewjulian dayjulian day number

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/condorcet-php-php-calendars/health.svg)

```
[![Health](https://phpackages.com/badges/condorcet-php-php-calendars/health.svg)](https://phpackages.com/packages/condorcet-php-php-calendars)
```

###  Alternatives

[fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

36473.2k8](/packages/fisharebest-ext-calendar)[iamfarhad/validation

🇮🇷 Complete Laravel Persian validation package - Iranian national ID, mobile numbers, Shamsi dates, IBAN/Sheba, postal codes &amp; more. Modern Laravel 10-12 support with both ValidationRule objects &amp; string-based rules.

2917.3k](/packages/iamfarhad-validation)[opilo/farsi

Farsi Tools for Dates and Numbers and Strings (with Laravel Validation Support)

333.2k1](/packages/opilo-farsi)[symfony_persia/symfonyjdate

Jalali (Shamsi) DateTime for Symfony2, Supports year higher than 2038

1010.6k](/packages/symfony-persia-symfonyjdate)

PHPackages © 2026

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