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.
$hijri_settings=array(
'langcode'=>'ar',
'defaultformat'=>'_j _M _Yهـ',
'umalqura'=TRUE,
'adj_data'=> array(1426 => 57250, 1429 => 57339,)
);
Tags
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
$s_hcal
protected
static Calendar
$s_hcal
static Calendar Object used to the last used Calendar
Tags
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
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