hanifhefaz / dcter
A composer package used to convert Jalali, Hijri, Gregorian and Julian dates to each others.
Fund package maintenance!
hanifhefaz
Installs: 1 280
Dependents: 0
Suggesters: 0
Security: 0
Stars: 24
Watchers: 3
Forks: 3
Open Issues: 0
Requires
- nesbot/carbon: ^2.16
Requires (Dev)
- phpunit/phpunit: 10.0.19
README
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.
- Jalali (Hijri Shamsi) 🔀 Gregorian
<?php use HanifHefaz\Dcter\Dcter; $date = "1401-01-16"; $gregorianDate = Dcter::JalaliToGregorian($date); return $gregorianDate; // returns 2022-04-05
- Gregorian 🔀 Jalali (Hijri Shamsi)
<?php use HanifHefaz\Dcter\Dcter; $date = "2023-04-08"; $jalaliDate = Dcter::GregorianToJalali($date); return $jalaliDate; // returns 1402-01-19
- Gregorian 🔀 Hijri (Hijri Qamari)
<?php use HanifHefaz\Dcter\Dcter; $date = "2023-04-08"; $hijriDate = Dcter::GregorianToHijri($date); return $hijriDate; // returns 1444-09-17
- Hijri (Hijri Qamari) 🔀 Gregorian
<?php use HanifHefaz\Dcter\Dcter; $date = "1444-09-17"; $gregorianDate = Dcter::HijriToGregorian($date); return $gregorianDate; // returns 2023-04-08
- Hijri (Hijri Qamari) 🔀 Julian
<?php use HanifHefaz\Dcter\Dcter; $date = "1444-09-17"; $julianDate = Dcter::HijriToJulian($date); return $julianDate; // returns 2460043
- Julian 🔀 Hijri (Hijri Qamari)
<?php use HanifHefaz\Dcter\Dcter; $date = "2460043"; $hijriDate = Dcter::JulianToHijri($date); return $hijriDate; // returns 1444-09-17
- Hijri 🔀 Jalali (Persian)
<?php use HanifHefaz\Dcter\Dcter; $date = "1444-09-23"; $hijriDate = Dcter::HijriToJalali($date); return $hijriDate; // returns 1402-01-25
- Jalali 🔀 Hijri (Hijri Qamari)
<?php use HanifHefaz\Dcter\Dcter; $date = "1402-01-25"; $hijriDate = Dcter::JalaliToHijri($date); return $hijriDate; // returns 1444-09-23
- 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: