Download the PHP package kfirba/hebdate without Composer
On this page you can find all versions of the php package kfirba/hebdate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kfirba/hebdate
More information about kfirba/hebdate
Files in kfirba/hebdate
Package hebdate
Short Description A library to convert jewish dates to gregorian dates and vice versa
License MIT
Informations about the package hebdate
Hebdate
Hebdate is a simple library that lets you easily convert gregorian dates to jewish dates, and vice versa, using several formats.
Installation
Install the package via composer:
composer require kfirba/hebdate
Basic Usage
Let's convert some dates:
Naturally, we can use it vice versa:
Actually, behind the scenes we are using two classes which you can choose whichever you want to use, the GregorianDate
class and the JewishDate
class.
By calling GregorianDate::fromJewish()
, you actually new up a JewishDate
instance. So it's identical to:
As you may have guessed, you can also call:
Input
As we have seen before, the classes are accepting different input formats:
-
GregorianDate::toJewish(INPUT_TYPE)
:- Array - A plain PHP array that represents the date in [dd, mm, yyyy] format.
- String - A string of a gregorian date in the format of mm/dd/yyyy. The delimiter may be a slash(/), a dot(.) or a dash(-). For example: 05-06-2016.
- Carbon Object - Any Carbon object.
- DateTime Object - Any DateTime object.
-
JewishDate::fromGregorian(INPUT_TYPE)
:- Has the same options as
GregorianDate::toJewish(INPUT_TYPE)
as it's just an alias.
- Has the same options as
-
JewishDate::toGregorian(INPUT_TYPE)
:- Array - an array that contains a hebrew date in [dd, mm, yyyy] format.
- Numeric String - A numeric string in "dd mm yyyy" format (note that the delimiter has to be a space). For example, 28 9 5776.
- English month numeric string - A numeric string with english month name. For example, 28 Iyar 5776.
- Full hebrew date string - A full hebrew string without any punctuation. For example, כח אייר התשעו.
- Full hebrew date string with punctuation - A full hebrew string with punctuation. For example, כח׳ אייר התשע״ו.
-
GregorianDate::fromJewish(INPUT_TYPE)
:- Has the same options as
JewishDate::toGregorian(INPUT_TYPE)
as it's just an alias.
- Has the same options as
Output
We can also specify which output format we want for the date. To do so, we just need to chain the format()
method and supply it with a format.
Note that the format constants are under Kfirba\Formats\Format
class.
Jewish Date Formats:
Gregorian Date Formats:
Extras
The convert()
method accepts a $delimiter
argument. When converting to Jewish dates it defaults to a space (" ") and when converting to Gregorian date it defaults to a slash (/).
The library also registers 2 global functions:
utf8_str_split($str = '', $len = 0)
which acts the same as PHP'sstr_split
function but works on UTF8 strings.isJewishLeapYear($year)
which determines whether the given year is a leap year. Note that the year has to be numeric and greater than 5000.
License
The Hebdate package is open-source project licensed under the MIT license.