PHPackages                             hussainweb/date-converter - 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. hussainweb/date-converter

ActiveLibrary

hussainweb/date-converter
=========================

DateConverter is a PHP library to convert dates from and to various calendar systems.

v1.0.0(3y ago)11.4k1GPL-2.0-or-laterPHPPHP ^7.4 | ^8.0CI passing

Since Jan 1Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/hussainweb/date-converter)[ Packagist](https://packagist.org/packages/hussainweb/date-converter)[ RSS](/packages/hussainweb-date-converter/feed)WikiDiscussions main Synced 1mo ago

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

Date Converter
==============

[](#date-converter)

[![Latest Version](https://camo.githubusercontent.com/143b17b59b11afc0b620fc7025fb19dd7fc83a11a5855f1817a3868b4aea4e21/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6875737361696e7765622f646174652d636f6e7665727465723f7374796c653d666c61742d737175617265)](https://github.com/hussainweb/date-converter/releases)[![Software License](https://camo.githubusercontent.com/d29b73b73c0d974cb5bda74c0d50ee9ea5be2439cbdb9d6cda893d351e41a824/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c76322d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/ccb8b96d9957ab7df9df8a0b009f96d03dd58703400a0dd62b877fcc7a20a32b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6875737361696e7765622f646174652d636f6e7665727465722f5048502532307465737473253230616e642532307374796c65253230636865636b733f7374796c653d666c61742d737175617265)](https://github.com/hussainweb/date-converter/actions/workflows/test.yml)[![Total Downloads](https://camo.githubusercontent.com/38baf2b41d98168328bd17f11c5b0f08b1baf793a9538e7bf7dfcc1088fd63dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6875737361696e7765622f646174652d636f6e7665727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hussainweb/date-converter)

Date Converter is a PHP library to convert dates across various calendars, including Gregorian, Hijri (various algorithms), and Unix timestamp (Native) representations.

Requirements
------------

[](#requirements)

The library requires PHP 7.4 or higher. It is tested on PHP 8.2, 8.3, 8.4, and 8.5.

Install
-------

[](#install)

Via Composer

```
composer require hussainweb/date-converter
```

Usage
-----

[](#usage)

To convert between dates, use the respective `Algorithm` class. Similar to [PHP's in-built date conversion functions](https://www.php.net/manual/en/function.gregoriantojd.php), these classes work with Julian Day as a primary means to convert dates.

Supported Calendars
-------------------

[](#supported-calendars)

Below are examples of how to use each supported calendar algorithm. Ensure you import the necessary classes using `use` statements at the beginning of your PHP file.

### Gregorian Calendar

[](#gregorian-calendar)

Example:

```
// Ensure you have:
// use Hussainweb\DateConverter\Algorithm\GregorianAlgorithm;
// use Hussainweb\DateConverter\Value\GregorianDate;

$gregorianAlgo = new GregorianAlgorithm();

// Convert Julian Day to Gregorian Date
// Example Julian Day: 2451545 (corresponds to 2000-01-01 Gregorian)
$gregorianDate = $gregorianAlgo->fromJulianDay(2451545);
echo "Gregorian Date: Day=" . $gregorianDate->getMonthDay() . ", Month=" . $gregorianDate->getMonth() . ", Year=" . $gregorianDate->getYear() . "\n";

// Convert Gregorian Date to Julian Day
$dateToConvert = new GregorianDate(1, 1, 2000); // Day, Month, Year
$julianDay = $gregorianAlgo->toJulianDay($dateToConvert);
echo "Julian Day: " . $julianDay . "\n";
```

### Hijri Calendar (Fatimid Astronomical)

[](#hijri-calendar-fatimid-astronomical)

Example:

```
// Ensure you have:
// use Hussainweb\DateConverter\Algorithm\Hijri\HijriFatimidAstronomical;
// use Hussainweb\DateConverter\Value\HijriDate;

$hijriAlgo = new HijriFatimidAstronomical();

// Convert Julian Day to Hijri Date
// Example Julian Day: 2457198 (corresponds to 8-9-1436 Hijri Fatimid Astronomical)
$hijriDate = $hijriAlgo->fromJulianDay(2457198);
echo "Hijri Date: Day=" . $hijriDate->getMonthDay() . ", Month=" . $hijriDate->getMonth() . ", Year=" . $hijriDate->getYear() . "\n";

// Convert Hijri Date to Julian Day
$dateToConvert = new HijriDate(8, 9, 1436, $hijriAlgo); // Day, Month, Year, Algorithm instance
$julianDay = $hijriAlgo->toJulianDay($dateToConvert);
echo "Julian Day: " . $julianDay . "\n";
```

### Native Calendar (Unix Timestamp)

[](#native-calendar-unix-timestamp)

Example:

```
// Ensure you have:
// use Hussainweb\DateConverter\Algorithm\NativeAlgorithm;
// use Hussainweb\DateConverter\Value\NativeDate;

$nativeAlgo = new NativeAlgorithm();

// Convert Julian Day to Native Date (Unix Timestamp)
// Example Julian Day: 2440588 (corresponds to Unix timestamp 0 -> 1970-01-01 00:00:00 UTC)
$nativeDate = $nativeAlgo->fromJulianDay(2440588);
echo "Native Date (Unix Timestamp): " . $nativeDate->getTimeStamp() . "\n";

// Convert Native Date (from Unix timestamp) to Julian Day
$timestamp = 0; // Example: 1970-01-01 00:00:00 UTC
$dateToConvert = new NativeDate($timestamp);
$julianDay = $nativeAlgo->toJulianDay($dateToConvert);
echo "Julian Day: " . $julianDay . "\n";
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance55

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% 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 ~863 days

Total

3

Last Release

1333d ago

PHP version history (2 changes)v1.0-beta1PHP ~5.6|~7.0

v1.0.0PHP ^7.4 | ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/085aa457eb46e449e7045c81d904cb31e53009485f8926af78651ca6e0676fcb?d=identicon)[hussainweb](/maintainers/hussainweb)

---

Top Contributors

[![hussainweb](https://avatars.githubusercontent.com/u/1040271?v=4)](https://github.com/hussainweb "hussainweb (56 commits)")[![google-labs-jules[bot]](https://avatars.githubusercontent.com/in/842251?v=4)](https://github.com/google-labs-jules[bot] "google-labs-jules[bot] (4 commits)")

---

Tags

datecalendarhijri

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/hussainweb-date-converter/health.svg)

```
[![Health](https://phpackages.com/badges/hussainweb-date-converter/health.svg)](https://phpackages.com/packages/hussainweb-date-converter)
```

###  Alternatives

[azuyalabs/yasumi

The easy PHP Library for calculating holidays

1.1k11.4M26](/packages/azuyalabs-yasumi)[league/period

Time range API for PHP

7335.4M21](/packages/league-period)[aeon-php/calendar

PHP type safe, immutable calendar library

2079.7M16](/packages/aeon-php-calendar)[yohang/calendr

Object Oriented calendar management

465614.1k3](/packages/yohang-calendr)[punic/punic

PHP-Unicode CLDR

1542.9M29](/packages/punic-punic)[umulmrum/holiday

A PHP library to compute holidays. It's something :-)

92342.6k1](/packages/umulmrum-holiday)

PHPackages © 2026

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