HijriDateLib

datetime extends DateTime
in package

Hijri Date custom extensions to the PHP DateTime class This handles the Hijri Calendar beside the Gregorian Calendar

This class override PHP DateTime Class to show the Hijri Calendar Date and also showing the Gregorian Calendar Translated to Arabic Language if language set to 'ar' the Hijri Calendar calculated depending of hijri\calendar Class which have two algorithms:

  • Hijri Tabular Algorithm.
  • Umm Al-Qura Algorithm.
to set the default setting of this class use $hijri_settings variable which is an array with this sample structure:
$hijri_settings=array(
'langcode'=>'ar',
'defaultformat'=>'_j _M _Y??',
'umalqura'=TRUE,
'adj_data'=> array(1426 => 57250, 1429 => 57339,)
);
Tags
copyright

2015-2022 Saeed Hubaishan

uses
Calendar

To convert date to hijri

license

LGPL

license

GPL-2

author

Saeed Hubaishan

version
2.3.2
category

datetime, calendar

link
http://salafitech.net

Table of Contents

$defaultformat  : string
$langcode  : string
$hcal  : Calendar
$s_hcal  : Calendar
__construct()  : mixed
Constructs a new instance of datetime, expanded to include an argument to inject the user context and modify the timezone to the users selected timezone if one is not set.
__toString()  : string
Magic method to convert DateTime object to string
createFromHijri()  : self
Create DateTime object from hijri date
format()  : mixed
setDateHijri()  : void
Resets the current date of the DateTime object to a different hijri date

Properties

$defaultformat

public string $defaultformat = '_j _M _Y?'

the default datetime format

$langcode

public string $langcode = 'ar'

language code can set to 'ar' to show Arabic Date

$hcal

protected Calendar $hcal

Calendar Object used to produce the Hijri Calendar from the timestamp

Tags
since
2.2.2

protected var

$s_hcal

protected static Calendar $s_hcal

static Calendar Object used to the last used Calendar

Tags
since
2.2.2

Methods

__construct()

Constructs a new instance of datetime, expanded to include an argument to inject the user context and modify the timezone to the users selected timezone if one is not set.

public __construct([string $time = 'now' ][, DateTimeZone $timezone = null ][, string $langcode = null ][, Calendar $hijriCalendar = null ]) : mixed
Parameters
$time : string = 'now'

String in a format accepted by strtotime() default is 'now'

$timezone : DateTimeZone = null

Time zone of the time default is ini timezone

$langcode : string = null

set the language which can be any of supported languages in Calendar object if not set the default is 'ar'

$hijriCalendar : Calendar = null

Calendar object which used for calendar converting, if not set the class will create new Calendar object with default settings

Tags
example

'examples/monthCalendar.php' 12 3 Create new DateTime

Return values
mixed

__toString()

Magic method to convert DateTime object to string

public __toString() : string
Return values
string

Formatted date time, according to the default settings in $hijri_settings variable

createFromHijri()

Create DateTime object from hijri date

public static createFromHijri(int $year, int $month, int $day[, DateTimeZone $timezone = null ][, string $langcode = null ][, Calendar $hijriCalendar = null ]) : self
Parameters
$year : int

the hijri year

$month : int

the hijri month

$day : int

the hijri day

$timezone : DateTimeZone = null

Optional the time zone object

$langcode : string = null

Optional the langcode

$hijriCalendar : Calendar = null

Optional the Calendar object

Return values
self

datetime object from the given hijri date

format()

public format([mixed $format = null ][, mixed $force_hijri = FALSE ]) : mixed
Parameters
$format : mixed = null
$force_hijri : mixed = FALSE
Return values
mixed

setDateHijri()

Resets the current date of the DateTime object to a different hijri date

public setDateHijri(int $year, int $month, int $day) : void
Parameters
$year : int

the hijri year

$month : int

the hijri month

$day : int

the hijri day

Return values
void

Search results