PHPackages                             kampute/civil-date - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. kampute/civil-date

ActiveLibrary[Localization &amp; i18n](/categories/localization)

kampute/civil-date
==================

Accurate Jalali, Gregorian, and Islamic date handling for PHP, with Persian calendar dates based on the official Nowruz rule.

v1.0.0(3d ago)00MITPHP ^8.1

Since Jul 5Compare

[ Source](https://github.com/kampute/civil-date-php)[ Packagist](https://packagist.org/packages/kampute/civil-date)[ RSS](/packages/kampute-civil-date/feed)WikiDiscussions Synced today

READMEChangelogDependencies (4)Versions (2)Used By (0)

Civil Date PHP Package
======================

[](#civil-date-php-package)

English | [فارسی](./README.fa.md)

This package handles Jalali, Gregorian, and Islamic dates with one consistent, predictable model. In the Jalali calendar, Nowruz and leap years follow the official Iranian calendar rule and the vernal equinox, not fixed approximate cycles.

Purpose
-------

[](#purpose)

Most Jalali date libraries use repeating arithmetic cycles to decide leap years. That is fast, but it is still an approximation. In some years, a cycle can place Nowruz on a different Gregorian day than the official calendar rule.

This library derives each Jalali year from the vernal equinox in Iran civil time. If the equinox occurs before local noon, Nowruz is that civil day; otherwise, Nowruz is the next civil day. Leap years follow from the number of days between one Nowruz and the next.

Features
--------

[](#features)

- Comprehensive date handling for Jalali, Gregorian, and Islamic calendars.
- Date construction from multiple sources: conversion from another calendar, from a day-of-year, from the nth weekday occurrence in a month or year, and more.
- Formatting and parsing of dates from text, including month and day names, seasons and eras, and numbers as digits or words, matching the locale.
- Date comparison by day, week, month, quarter, and year.
- Creating new dates by adding or subtracting days, months, or years.
- Jalali leap years and year lengths based on astronomical Nowruz.
- Configurable Islamic month lengths for applications that need authoritative 29- or 30-day month data.
- PHP 8.1+ support, PSR-4 autoloading, and no runtime dependencies.

Installation
------------

[](#installation)

Install with Composer:

```
composer require kampute/civil-date
```

Quick Start
-----------

[](#quick-start)

```
