DaynumPHP1.0 · Beta

One date.
More ways to read it.

Work with Gregorian, Jalali and Hijri dates in PHP. Convert, format and calculate through one consistent API—without changing the original value.

composer require eram/daynum:^1.0@beta

A DATE, IN TRANSLATION

Same day. Different calendars.

Recorded PHP examples
Gregorian
Wednesday08

April 2026

gregorian()
Jalali
Wednesday19

Farvardin 1405

jalali()
Hijri · Umm al-Qura
Wednesday20

Shawwal 1447

hijri()
2026-04-08

One shared date value

See the PHP
use Eram\Daynum\CivilDateTime;

$date = CivilDateTime::fromGregorian(2026, 4, 8);

$date->gregorian()->format('Y/m/d'); // 2026/04/08
$date->jalali()->format('Y/m/d');    // 1405/01/19
$date->hijri()->format('Y/m/d');     // 1447/10/20

$date->jalali()->withLocale('fa')->withDigits('persian')
    ->format('l j F Y'); // چهارشنبه ۱۹ فروردین ۱۴۰۵

Choose a date to see results generated with Daynum 1.0.0-beta.4. These examples do not run PHP in your browser.

BEYOND CONVERSION

For the dates your app actually handles.

SHAHRIVAR311405
+1 month
MEHR301405

A month is a calendar month.

Shahrivar has 31 days. Mehr has 30. Add a Jalali month and Daynum uses the last valid day; the original date stays unchanged.

See the PHP
use Eram\Daynum\CivilDateTime;

$date = CivilDateTime::fromJalali(1405, 6, 31);
$next = $date->jalali()->addMonths(1);

$next->jalali()->format('Y/m/d'); // 1405/07/30
$date->jalali()->format('Y/m/d'); // 1405/06/31
A date from your form
۱۴۰۵/۰۱/۱۹
2026-04-08Gregorian
۱۴۰۵/۰۷/۳۱No day 31 in Mehrnull

Read Persian input. Reject invalid dates.

Parse a known format with Persian digits. tryParseExact returns null for an invalid date, so your form can ask the user to correct it.

See the PHP
use Eram\Daynum\Calendar\Jalali\JalaliView;

$date = JalaliView::tryParseExact('۱۴۰۵/۰۱/۱۹', 'Y/m/d');
$date?->gregorian()->format('Y-m-d'); // 2026-04-08

JalaliView::tryParseExact('۱۴۰۵/۰۷/۳۱', 'Y/m/d'); // null

THE DETAILS MATTER

Explicit where it counts.

Choose the calendar and locale your application needs. Keep calendar calculations separate from elapsed-time calculations.

A QUICK COMPARISON

Choose for the job in front of you.

LibraryA good fit forApproach
DaynumSeveral calendars, one PHP API

Gregorian, Jalali and two Hijri calendars. Immutable values; no Composer runtime dependencies or ext-intl requirement.

Civil-time arithmetic. Use native PHP for elapsed time across timezones.
morilog/jalaliA Jalali-focused application

An immutable Jalalian API for Shamsi dates, with conversion to and from Carbon and DateTime.

A focused choice when Jalali is the calendar you need.
CarbonTimezones and everyday date-time work

Extends PHP DateTime with expressive date arithmetic, relative parsing and localized output. CarbonImmutable is also available.

Can sit alongside Daynum when your app needs both timezone and calendar operations.

Based on the linked project documentation, reviewed October 8, 2026. This compares scope, not speed.

Moving from morilog/jalali? Read the migration guide

Start with a date you know.

Install Daynum, choose a calendar and try it in your project.

Read the getting started guide
Requires
PHP 8.1+
Runtime packages
None
License
MIT