PHPackages                             fisharebest/ext-calendar - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. fisharebest/ext-calendar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

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.

2.6.0(3y ago)36473.2k—5%5[1 PRs](https://github.com/fisharebest/ext-calendar/pulls)8GPL-3.0-or-laterPHPPHP &gt;=5.3.0

Since Sep 10Pushed 1y ago3 watchersCompare

[ Source](https://github.com/fisharebest/ext-calendar)[ Packagist](https://packagist.org/packages/fisharebest/ext-calendar)[ Docs](https://github.com/fisharebest/ext-calendar)[ RSS](/packages/fisharebest-ext-calendar/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (21)Used By (8)

[![Build Status](https://camo.githubusercontent.com/96978bab1854220f21bf2dc0600f30ab1c5d3237b19ae58eb0cca445ba2890c9/68747470733a2f2f7472617669732d63692e6f72672f66697368617265626573742f6578742d63616c656e6461722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/fisharebest/ext-calendar)[![Coverage Status](https://camo.githubusercontent.com/fb435197b84db88f882d34121d1946eb1064973371808b700aac339008cff7b2/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f66697368617265626573742f6578742d63616c656e6461722f62616467652e706e67)](https://coveralls.io/r/fisharebest/ext-calendar)[![SensioLabsInsight](https://camo.githubusercontent.com/d4ffd83fbc381c83f0b1a810d4feb38fd4dc8af55baa8301f608f74b4e79602b/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f39353264366531312d363934312d343437622d393735372d6663386462633364326131662f6d696e692e706e67)](https://insight.sensiolabs.com/projects/952d6e11-6941-447b-9757-fc8dbc3d2a1f)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e70047974c527e689feeb98f85c2452b8cdb462cfa0907acd3b98d939ef468ef/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f66697368617265626573742f6578742d63616c656e6461722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/fisharebest/ext-calendar/?branch=master)[![StyleCI](https://camo.githubusercontent.com/1b4cf404a47ae1375fca125a8ffbb28ddfb19036c2737f1ef8b0310d798eae2f/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f32353937343033362f736869656c64)](https://github.styleci.io/repos/25974036)[![Code Climate](https://camo.githubusercontent.com/e486c3e4a92f87573da91a7b30d8d96cb329be399e13ee61d27d86f8faaa79a6/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f66697368617265626573742f6578742d63616c656e6461722f6261646765732f6770612e737667)](https://codeclimate.com/github/fisharebest/ext-calendar)

PHP calendar functions
======================

[](#php-calendar-functions)

This package provides an 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 replacement for PHP‘s [ext/calendar](https://php.net/calendar) extension. It allows you to use the following PHP functions on servers that do not have the ext/calendar extension installed (such as HHVM).

- [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)

How to use it
=============

[](#how-to-use-it)

Add the package as a dependency in your `composer.json` file:

```
require {
    "fisharebest/ext-calendar": "~2.5"
}
```

Now you can use the PHP functions, whether `ext/calendar` is installed or not. Since version 2.2, it is no longer necessary to initialise these using `Shim::create()`.

```
require 'vendor/autoload.php';
print_r(cal_info(CAL_GREGORIAN)); // Works in HHVM, or if ext-calendar is not installed
```

Alternatively, just use the calendar classes directly.

```
require 'vendor/autoload.php';

// Create calendars
$calendar = new Fisharebest\ExtCalendar\ArabicCalendar;
$calendar = new Fisharebest\ExtCalendar\FrenchCalendar;
$calendar = new Fisharebest\ExtCalendar\GregorianCalendar;
$calendar = new Fisharebest\ExtCalendar\JewishCalendar;
$calendar = new Fisharebest\ExtCalendar\JulianCalendar;
$calendar = new Fisharebest\ExtCalendar\PersianCalendar;

// Date conversions
$julian_day = $calendar->ymdToJd($year, $month, $day);
list($year, $month, $day) = $calendar->jdToYmd($julian_day);

// Information about days, weeks and months
$is_leap_year   = $calendar->isLeapYear($year);
$days_in_month  = $calendar->daysInMonth($year, $month);
$months_in_year = $calendar->monthsInYear();       // Not all calendars have 12
$months_in_year = $calendar->monthsInYear($year);  // In a specific year
$days_in_week   = $calendar->daysInWeek();         // Not all calendars have 7

// Which dates are valid for this calendar?
$jd = $calendar->jdStart();
$jd = $calendar->jdEnd();

// Miscellaneous utilities
$jewish = new JewishCalendar;
$jewish->numberToHebrewNumerals(5781, false); // "תשפ״א"
$jewish->numberToHebrewNumerals(5781, true);  // "ה׳תשפ״א"
```

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

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

When faced with invalid inputs, the shim functions trigger `E_USER_WARNING` instead of `E_WARNING`. The text of the error messages is the same.

The functions `easterdate()` and `jdtounixtime()` use PHP‘s timezone, instead of the operating system‘s timezone. These may be different.

Compatibility with different versions of PHP
============================================

[](#compatibility-with-different-versions-of-php)

The following PHP bugs are emulated, according to the version of PHP being used. Thus the package always provides the same behaviour as the native `ext/calendar` extension.

- [\#54254](https://bugs.php.net/bug.php?id=54254) Jewish month "Adar" - fixed in PHP 5.5.
- [\#67960](https://bugs.php.net/bug.php?id=67960) Constants `CAL_DOW_SHORT` and `CAL_DOW_LONG` - found and [fixed](https://github.com/php/php-src/commit/244fc1e05367dc7ebdf2db260c8bc8b106563d26) by this project - fixed in PHP 5.5.21 and 5.6.5.
- [\#67976](https://bugs.php.net/bug.php?id=67976) Wrong value in `cal_days_in_month()` for French calendar - found by this project.

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

[](#development-and-contributions)

Due to the known restrictions above, you may need to run unit tests using `TZ=UTC phpunit`.

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

History
=======

[](#history)

These functions were originally written for the [webtrees](http://www.webtrees.net)project. As part of a refactoring process, they were extracted to a standalone library, given version numbers, unit tests, etc.

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

44

—

FairBetter than 92% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

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

Every ~156 days

Recently: every ~462 days

Total

19

Last Release

1448d ago

Major Versions

1.3.0 → 2.0.02015-03-31

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2306088?v=4)[Greg Roach](/maintainers/fisharebest)[@fisharebest](https://github.com/fisharebest)

---

Top Contributors

[![fisharebest](https://avatars.githubusercontent.com/u/2306088?v=4)](https://github.com/fisharebest "fisharebest (69 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

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fisharebest-ext-calendar/health.svg)

```
[![Health](https://phpackages.com/badges/fisharebest-ext-calendar/health.svg)](https://phpackages.com/packages/fisharebest-ext-calendar)
```

###  Alternatives

[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)[phpu/calendar

中国日历，通过天文计算和民间推算方法，准确计算出公历-1000年至3000年的农历、干支、节气等，同时支持多配置、多语言、多时区。

201.7k](/packages/phpu-calendar)[p3ym4n/jdate

Date converter from Jalali to Georgian and vice versa. It has Carbon instance inside and it's Laravel friendly.

101.8k2](/packages/p3ym4n-jdate)

PHPackages © 2026

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