1. Go to this page and download the library: Download rizqshadi/hijri-date library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rizqshadi / hijri-date example snippets
use RizqShadi\HijriDate\Hijri;
use RizqShadi\HijriDate\Location;
$hijri = new Hijri(Location::fromTimezone('Asia/Riyadh'));
echo $hijri->today()->format('j F Y'); // e.g. 15 Rabi' al-Thani 1448
echo $hijri->today()->format('j F Y', 'ar'); // e.g. 15 ربيع الآخر 1448
echo $hijri->untilRamadan()->toString('en'); // e.g. 4 months and 16 days until Ramadan 1448
use RizqShadi\HijriDate\Location;
Location::fromTimezone('Asia/Riyadh'); // lat/lng + country from the tz database
Location::fromCoordinates(21.4225, 39.8262); // nearest timezone → Asia/Riyadh
Location::fromCoordinates(21.4225, 39.8262, 'Asia/Riyadh'); // explicit timezone
Location::fromCountry('SA'); // the country's main timezone
Location::default(); // PHP's default timezone
$hijri = new Hijri(Location::fromTimezone('Asia/Riyadh'));
$today = $hijri->today();
$today->year; // 1448
$today->month; // 4
$today->day; // 15
$today->gregorian; // DateTimeImmutable 2026-09-26 00:00 Asia/Riyadh
(string) $today; // "1448-04-15"
// The Hijri date at a specific instant, as seen at the location:
$hijri->at(new DateTimeImmutable('2026-09-26 22:30', new DateTimeZone('UTC'))); // 1448-04-16 in Riyadh
$date = $hijri->fromGregorian('2026-02-18');
$date->format('l, j F Y'); // Wednesday, 1 Ramadan 1447
$date->format('d/m/Y'); // 01/09/1447
$date->format('l j F Y هـ', 'ar', true); // الأربعاء ١ رمضان ١٤٤٧ هـ
$date->format('\Y\e\a\r: Y'); // Year: 1447
$date->monthName('ar'); // رمضان
$date->dayName(); // Wednesday
$date->isRamadan(); // true
$date->toArray(); // ['year' => 1447, 'month' => 9, 'day' => 1, 'month_name' => 'Ramadan', ...]
json_encode($date);
$countdown = $hijri->untilRamadan(); // from today
$countdown = $hijri->untilRamadan('2026-09-26'); // from a given date
$countdown->months; // 4
$countdown->days; // 16
$countdown->totalDays; // 135 (real day difference)
$countdown->ramadanStart; // HijriDate 1448-09-01 (->gregorian = 2027-02-08)
$countdown->from; // HijriDate you counted from
$countdown->isRamadanNow; // false
$countdown->dayOfRamadan; // null (or 1-30 during Ramadan)
echo $countdown->toString('en'); // 4 months and 16 days until Ramadan 1448
echo $countdown->toString('ar'); // باقي 4 أشهر و16 يومًا على رمضان 1448
json_encode($countdown);
echo "Today: " . $date->format('j F Y', 'ar', rtl: true); // renders correctly inside LTR text
echo $countdown->toString('ar', arabicDigits: true, rtl: true); // باقي ٤ أشهر و١٦ يومًا على رمضان ١٤٤٨
use RizqShadi\HijriDate\Rtl;
Rtl::isolate($anyArabicText);
Rtl::strip($text); // remove bidi control characters before storing or comparing
use RizqShadi\HijriDate\Rtl;
echo Rtl::visual($countdown->toString('ar', arabicDigits: true, rtl: true)) . PHP_EOL;
// or for a whole CLI script:
ob_start(fn (string $out) => Rtl::visual($out));
use RizqShadi\HijriDate\CalendarType;
$civil = new Hijri($location, CalendarType::Civil); // no ext-intl
$hijri = new Hijri($location, adjustment: 1); // or $hijri->withAdjustment(-1)
$hijri->fromGregorian('2026-02-18'); // 1447-09-02 instead of 1447-09-01
$hijri->toGregorian(1447, 9, 1); // 2026-02-17
$hijri = new Hijri(Location::fromCoordinates(21.4225, 39.8262), dayStartsAtSunset: true);
// or $hijri->withDayStartsAtSunset();
$hijri->at(new DateTimeImmutable('2026-09-26 12:00', new DateTimeZone('Asia/Riyadh'))); // 1448-04-15
$hijri->at(new DateTimeImmutable('2026-09-26 20:00', new DateTimeZone('Asia/Riyadh'))); // 1448-04-16
use RizqShadi\HijriDate\Converter\IntlConverter;
use RizqShadi\HijriDate\Converter\TabularConverter;
(new TabularConverter())->toHijri(2026, 2, 18); // [1447, 9, 1]
(new IntlConverter('islamic-umalqura'))->toGregorian(1446, 1, 1); // [2024, 7, 7]
bash
# Debian/Ubuntu
sudo apt install php-intl
# Windows: enable it in php.ini
extension=intl