Download the PHP package kindy/hijridate without Composer
On this page you can find all versions of the php package kindy/hijridate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kindy/hijridate
More information about kindy/hijridate
Files in kindy/hijridate
Package hijridate
Short Description Package for Hijri date conversion and manipulation in PHP
License MIT
Homepage https://github.com/mrkindy/hijridate
Informations about the package hijridate
Kindy Hijri Date Package
This PHP package provides functionalities for handling Hijri (Islamic) dates, including conversion, formatting, and integration with Gregorian calendars. The package features enhanced modularity and functionality, making it highly useful for PHP developers requiring Hijri date processing.
Features
-
Hijri Calendar Compliance:
- Fully adheres to the astronomical conventions used by astronomers and matches the standards in Microsoft products and the Calendar of the Centuries by Dr. Saleh Al-Ojairi.
- Includes full support for the Umm Al-Qura calendar.
-
Custom Calendar Adjustments:
- Supports saving and restoring calendar adjustments, allowing customization to reflect specific events like Ramadan and Eid declarations.
-
Hijri and Gregorian Integration:
- Combines both calendars seamlessly in a single programming operation.
- Uses
date
-style format characters prefixed with_
for Hijri date formatting.
-
Language Support:
- Includes 20 global languages for Hijri month names.
- Displays Gregorian dates in Arabic when the language is set to Arabic.
- Integration with PHP
DateTime
:- Fully compatible with PHP's
DateTime
class, with additional methods for Hijri-specific functionalities. - Automatically handles timezone differences.
- Fully compatible with PHP's
Installation
You can install the package via Composer:
Namespace and Class Structure
The package follows a modular approach with the following structure:
- Namespace:
Kindy\HijriDate
- Classes:
HijriDateTime
: Handles Hijri date and time functionalities.Calendar
: Provides core conversion and calculation utilities.CalendarAdjustment
: Enables custom calendar adjustments.
Usage
Basic Example: Display Current Hijri Date
HijriDateTime Class
Constructor
time
: String in a format accepted by strtotime() default is 'now'$timezone
: Time zone of the time default is ini timezonelangcode
: Default language (ar
for Arabic, others default to English).calendar
: Calendar object which used for calendar converting, if not set the class will create Calendar object with default settings.
Format Hijri Dates
Format Hijri Dates
Hijri Dates Static Method
Hijri Dates objet by new instance
Hijri and Gregorian Dates Together
Convert Specific Gregorian Date to Hijri
Create Hijri Date Object from Hijri Date
Formatting Time and Date in the Hijri Calendar
The function formats time and date using specific characters, with no differences in parameters but varying outputs depending on the characters used. Below is a table explaining the functionality of each character:
Character | Description | Example Output |
---|---|---|
_j | Day without leading zeros | 1-30 |
_d | Day with leading zeros | 01-30 |
S | Ordinal suffix (English only, new in version 2.3) | st-nd-th |
_z | Day of the year (starting from zero) | 0-354 |
_M, _F | Month name | محرم, صفر, ... |
_m | Month number with leading zeros | 01-12 |
_n | Month number without leading zeros | 1-12 |
_t | Number of days in the month | 29-30 |
_L | Leap year indicator (1 = Leap Year, 0 = Not Leap Year) | 1 or 0 |
_Y | Full year number | 1436 |
_y | Two-digit year | 36 |
Adjusted Gregorian Date Formatting in Arabic Language
When selecting the Arabic language, some Gregorian date formatting characters are adjusted as follows:
Character | Description | Example Output |
---|---|---|
l, D | Day of the week name | السبت, الأحد... |
F | Month names in Syriac terms | كانون الثاني, شباط... |
M | Month names in English terms | يناير, فبراير... |
a | AM/PM in Arabic symbols | ص-م |
A | AM/PM in Arabic full text | صباحا - مساء |
Extended Features
Additional Methods
The HijriDateTime
class includes custom methods for Hijri-specific functionalities:
-
HijriDateTime::createFromHijri(year, month, day)
: Creates aHijriDateTime
object from a specific Hijri date. HijriDateTime::setDateHijri(year, month, day)
: Sets the Hijri date for an existingHijriDateTime
object.
Calendar Class
The Calendar
class provides low-level utilities such as:
- Conversion between Julian and Hijri calendars.
- Determining leap years.
- Validating Hijri dates.
Example: Days in Hijri Month
Using the Package with Legacy Code
If you want to use this library without changing existing DateTime
-dependent code, alias HijriDateTime
as DateTime
:
Alternatively, create a custom hdate()
function to replace PHP's date()
:
Contributing
Your contribution is welcome
Credits
License
This package is licensed under GPL-2 License.
Note: For detailed documentation and examples, refer to the official API or the examples.php
file in the repository.