Download the PHP package rizqshadi/hijri-date without Composer

On this page you can find all versions of the php package rizqshadi/hijri-date. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hijri-date

Hijri Date

A Hijri (Islamic) calendar library for PHP 8.1+.

Requirements

Installation

About ext-intl

Calendar CalendarType Needs
Umm al-Qura (default) CalendarType::UmmAlQura ext-intl (ICU)
Tabular / civil CalendarType::Civil nothing, pure PHP

If you request Umm al-Qura without intl, an IntlNotAvailableException explains how to install it. The library never silently falls back to the civil calendar, because the two can differ by a day or two.

Quick start

Usage

Location

"Today" depends on the local date: 1 am in Riyadh is still the previous day in New York.

Today's date

Gregorian → Hijri

Hijri → Gregorian

Formatting

format($pattern, $locale = 'en', $arabicDigits = false, $rtl = false) accepts PHP date()-style tokens:

Token Meaning Example
j day 1
d day, 2 digits 01
n month 9
m month, 2 digits 09
F month name Ramadan / رمضان
Y year 1447
y year, 2 digits 47
l weekday name Wednesday / الأربعاء

Prefix a character with a backslash to print it literally.

Ramadan countdown

Arabic and right-to-left display

Arabic output is plain text in logical order. It displays correctly in any right-to-left context, such as an HTML element with dir="rtl":

When Arabic is mixed into left-to-right text (English sentences, logs, LTR UIs), the Unicode bidi algorithm can reorder the surrounding numbers. For example, (1 رمضان 1447) displays as (1447 رمضان 1). Pass rtl: true to wrap Arabic output in an invisible right-to-left isolate (U+2067 … U+2069):

rtl is off by default so that stored and compared strings contain no invisible characters. It only affects 'ar' output.

Terminals / CLI

Most terminals (the VS Code terminal, Windows Terminal, the Windows console) support neither right-to-left text nor Arabic letter joining. They draw characters left to right in stored order, so Arabic appears reversed with unjoined letters. Rtl::visual() prepares text for them. It joins the letters into their connected forms (including لا) and reorders each line with the Unicode Bidirectional Algorithm, keeping numbers left to right and honouring rtl: true isolates:

Use Rtl::visual() only for such displays. Never use it for HTML, databases or APIs. A bidi-aware display (browser, GNOME Terminal, Konsole) reverses the text itself and would show it backwards.

Calendar choice

Moon-sighting adjustment

Local announcements can differ from Umm al-Qura by a day. Shift the calendar by -2 to +2 days:

Day starts at sunset

The Islamic day begins at maghrib. With this option, the Hijri date advances once local time passes sunset. Sunset is computed with PHP's built-in date_sun_info() from the location's coordinates:

Immutability

Hijri, Location, HijriDate and RamadanCountdown are immutable. The with*() methods return new instances: withLocation(), withCalendar(), withAdjustment(), withDayStartsAtSunset().

Exceptions

Every exception implements RizqShadi\HijriDate\Exception\HijriDateException, so one catch handles them all:

Low-level converters

Conversions are done at 12:00 UTC, so DST and midnight edge cases cannot shift the result. The converters don't validate their input; Hijri does.

Example

A runnable example prints today's date in Riyadh (English and Arabic), both conversions and the Ramadan countdown:

On a terminal it passes its output through Rtl::visual(). If your terminal handles right-to-left text itself, set HIJRI_TERMINAL_BIDI=1.

Testing

From a clone of the repository:

The tests check known Umm al-Qura dates against ICU and round-trip conversions over 20 years. They also compare the pure-PHP civil calendar with ICU's islamic-civil day by day over 40 years, and cover timezones, sunset rollover, adjustments and every Ramadan countdown edge case.

Support

Found a bug or have a question? Open an issue at github.com/ShadiRq/hijri-date.

License

MIT © Shadi Rizq. See LICENSE.


All versions of hijri-date with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rizqshadi/hijri-date contains the following files

Loading the files please wait ...