hanifhefaz/dcter

A composer package used to convert Jalali, Hijri, Gregorian and Julian dates to each others.

Fund package maintenance!
hanifhefaz

1.1.6 2023-04-14 11:49 UTC

This package is auto-updated.

Last update: 2024-10-19 10:41:31 UTC


README

Latest Stable Version Total Downloads Tests GitHub Issues

A composer package that is used to convert dates between Hijri, Jalali, Gregorian and Julian calendars.

Please consider a ⭐ as your support if you think this is helpful.

🔰 Installation

composer require hanifhefaz/dcter

❓ Usage

This package currently consists of 8 methods namely, HijriToGregorian, GregorianToHijri, JulianToHijri, HijriToJulian, GregorianToJalali, JalaliToGregorian, HijriToJalali, JalaliToHijri to convert dates to each other, and Carbonize method to make a carbon date object from any date in YYYY-MM-DD format, which comes from the popular Carbon package.

each method can be used the same way as we used the one in example, but the JulianToHijri takes the input parameter in julian format, where the output will be a hijri date and the HijriToJulian takes the input parameter as hijri date, and the output will be a julian format.

  1. Jalali (Hijri Shamsi) 🔀 Gregorian
<?php
use HanifHefaz\Dcter\Dcter;

$date = "1401-01-16";
    $gregorianDate = Dcter::JalaliToGregorian($date);
    return $gregorianDate; // returns 2022-04-05
  1. Gregorian 🔀 Jalali (Hijri Shamsi)
<?php
use HanifHefaz\Dcter\Dcter;

$date = "2023-04-08";
    $jalaliDate = Dcter::GregorianToJalali($date);
    return $jalaliDate; // returns 1402-01-19
  1. Gregorian 🔀 Hijri (Hijri Qamari)
<?php
use HanifHefaz\Dcter\Dcter;

$date = "2023-04-08";
    $hijriDate = Dcter::GregorianToHijri($date);
    return $hijriDate; // returns 1444-09-17
  1. Hijri (Hijri Qamari) 🔀 Gregorian
<?php
use HanifHefaz\Dcter\Dcter;

$date = "1444-09-17";
    $gregorianDate = Dcter::HijriToGregorian($date);
    return $gregorianDate; // returns 2023-04-08
  1. Hijri (Hijri Qamari) 🔀 Julian
<?php
use HanifHefaz\Dcter\Dcter;

$date = "1444-09-17";
    $julianDate = Dcter::HijriToJulian($date);
    return $julianDate; // returns 2460043
  1. Julian 🔀 Hijri (Hijri Qamari)
<?php
use HanifHefaz\Dcter\Dcter;

$date = "2460043";
    $hijriDate = Dcter::JulianToHijri($date);
    return $hijriDate; // returns 1444-09-17
  1. Hijri 🔀 Jalali (Persian)
<?php
use HanifHefaz\Dcter\Dcter;

$date = "1444-09-23";
    $hijriDate = Dcter::HijriToJalali($date);
    return $hijriDate; // returns 1402-01-25
  1. Jalali 🔀 Hijri (Hijri Qamari)
<?php
use HanifHefaz\Dcter\Dcter;

$date = "1402-01-25";
    $hijriDate = Dcter::JalaliToHijri($date);
    return $hijriDate; // returns 1444-09-23
  1. YYYY-MM-DD 🔀 Carbonize
<?php
use HanifHefaz\Dcter\Dcter;

$date = "1402-01-25";
    $carbonDate = Dcter::Carbonize($date);
    return $carbonDate; // returns 1402-01-25 00:00:00

🎭 Contributions

Contributions are most welcome!

Please read the Contributions file.

❤️ Contributors

People who contributed to this package: