Introduction
Zman is a PHP package that makes Jewish date conversions simple and easy.
The Zman
class is inherited from the amazing briannesbitt/Carbon which in turn inherits from PHP’s DateTime class, thus giving us access to some pretty nifty methods.
Getting Started
Use Composer
1 | $ composer require zman/zman |
1 | <?php |
Instantiation
There are five different ways to create a new instance of Zman
.
1 | $zman = new Zman('first day of November 2016'); |
Conversions
Every instance of Zman
contains information about a day’s Gregorian calendar date as well as its Jewish calendar date. Thus, for any conversion, simply create a new instance of Zman
with the day in question (Gregorian or Jewish) and access the desired converted properties.
For example:
1 | $zman = Zman::createFromDate(1993, 2, 21); |
String Formats
All of the toXXXString()
methods defined by Carbon are also available on Zman
. Additionally, there are a few methods specific to printing the Jewish date as a string in both English and Hebrew.
1 | $zman = Zman::parse('1993-2-21 14:15:16'); |
Of course, you can always build up your own string by combining the getters.
Getters
Zman
inherits all getters from Carbon, so you’ll always have month
, day
, year
, hour
, dayOfWeek
, etc. Additionally, Zman
provides getters specific to its Jewish date properties.
The getters are implemented via PHP’s __get()
method, enabling access to the value as if it was a property rather than a function call.
1 | $zman = Zman::parse('1993-2-21 23:26:11.123789'); |
An additional set of getters is available to summarize the current day’s holidays.
1 | $zman = Zman::parse('April 11, 2017'); |
More on holidays can be found in the Moadim section.
Setters
Zman
inherits all setters from Carbon, so you’ll always have month
, day
, year
, hour
, dayOfWeek
, etc. Additionally, Zman
provides setters specific to its Jewish date properties. However, no validation is performed whatsoever for the Jewish properties so only use these methods if you’re sure you know what you’re doing.
The setters are implemented via PHP’s __set()
method, enabling access to the value as if it was a property rather than a function call.
1 | $zman = Zman::parse('February 21, 1993'); |
Addition and Subtraction
Since Zman
inherits Carbon, all of the addition and subtraction methods Carbon provides are available (addDay
, addMonth
, etc.). See the Carbon docs for more information.
Parshas HaShavua
The Parshas Hashavua for any date can be retrieved via the parsha
getter. A few examples are shown below.
1 | Zman::parse('10/26/16')->parsha // Breishis |
In addition, the Parshas Hashavua can be retrieved in Hebrew.1
2
3
4
5Zman::parse('10/26/16')->parshaHebrew // בראשית
Zman::parse('11/1/16')->parshaHebrew // נח
Zman::parse('2/22/17')->parshaHebrew // משפטים
Zman::parse('5/4/17')->parshaHebrew // אחרי מות - קדושים
Zman::parse('9/21/17')->parshaHebrew // האזינו
Moadim
In addition to manually converting dates, Zman
supports finding and checking for all of the Jewish holidays and Moadim. Leap years and days that are nidchech are taken care of so you don’t need to worry about it.
Holidays
There are convenience methods for finding the Gregorian date of any holiday for a given year, as well as checking if a specific Gregorian date is any of the holidays.
Rosh Hashana
1 | Zman::firstDayOfRoshHashana('5777')->toFormattedDateString(); // Oct 3, 2016 |
Yom Kippur
1 | Zman::dayOfYomKippur('5777')->toFormattedDateString(); // Oct 12, 2016 |
Sukkos
1 | Zman::firstDayOfSukkos('5777')->toFormattedDateString(); // Oct 17, 2016 |
Shmini Atzeres
1 | Zman::dayOfShminiAtzeres('5777')->toFormattedDateString(); // Oct 24, 2016 |
Simchas Torah
1 | Zman::dayOfSimchasTorah('5777')->toFormattedDateString(); // Oct 25, 2016 |
Chanuka
1 | Zman::firstDayOfChanuka('5777')->toFormattedDateString(); // Dec 25, 2016 |
Tu Bishvat
1 | Zman::dayOfTuBishvat('5777')->toFormattedDateString(); // Feb 11, 2017 |
Purim
1 | Zman::dayOfPurim('5777')->toFormattedDateString(); // Mar 12, 2017 |
Shushan Purim
1 | Zman::dayOfShushanPurim('5777')->toFormattedDateString(); // Mar 13, 2017 |
Purim Kattan
1 | Zman::dayOfPurimKattan('5779')->toFormattedDateString(); // Feb 19, 2019 |
Pesach
1 | Zman::firstDayOfPesach('5777')->toFormattedDateString(); // Apr 11, 2017 |
Pesach Sheni
1 | Zman::dayOfPesachSheni('5777')->toFormattedDateString(); // May 10, 2017 |
Shavuos
1 | Zman::firstDayOfShavuos('5777')->toFormattedDateString(); // May 31, 2017 |
Outside of Eretz Yisroel is the default setting. To find the value specific to Israel pass false
as the second parameter. (e.g. Zman::dayOfSimchasTorah('5777', false)
)
Fast Days
There are convenience methods for finding the Gregorian date of any fast day for a given year, as well as checking if a specific Gregorian date is any of the fast days.
Yom Kippur
1 | Zman::dayOfYomKippur('5777')->toFormattedDateString()); // Oct 12, 2016 |
Tzom Gedaliah
1 | Zman::dayOfTzomGedaliah(5777)->toFormattedDateString()); // Oct 5, 2016 |
Asara Biteives
1 | Zman::dayOfAsaraBiteives(5777)->toFormattedDateString(); // Jan 8, 2017 |
Taanis Esther
1 | Zman::dayOfTaanisEsther(5777)->toFormattedDateString(); // Mar 9, 2017 |
Shiva Asar Bitamuz
1 | Zman::dayOfShivaAsarBitamuz(5777)->toFormattedDateString(); // Jul 11, 2017 |
Tisha Bav
1 | Zman::dayOfTishaBav(5777)->toFormattedDateString(); // Aug 1, 2017 |
General
1 | Zman::parse('October 5, 2016')->isFastDay()); // true |
Yuntif
In some cases you may want to check if it is actually Yuntif. Here’s how you can:
1 | Zman::parse('April 11, 2017')->isPesachYuntif(); // true - Pesach |
Chol Hamoed
In some cases you may want to check if it is Chol Hamoed. Here’s how you can:
1 | Zman::parse('April 13, 2017')->isCholHamoed(); // true |
Rosh Chodesh
1 | Zman::parse('November 1, 2016')->isRoshChodesh(); // true |
Aseres Yimei Teshuva
1 | Zman::parse('September 21, 2017')->isAseresYimeiTeshuva(); // true |
Davening
A few handy boolean checks have been implemented to check for special additions to davening.
Leining
To check if a day has leining, just use the hasLeining
method.
1 | Zman::parse('November 7, 2016')->hasLeining(); // true - Monday |
To check if a day has leining during a specific minyan, use the leiningAt
method as shown below.1
2
3
4
5
6
7
8
9
10
11// Weekdays
Zman::parse('November 7, 2016')->leiningAt('shacharis') // Lech Licha
// Holidays
Zman::parse('December 27, 2016')->leiningAt('shacharis') // Chanuka
// Shabbos Mincha
Zman::parse('November 12, 2016')->leiningAt('mincha') // Vayera
// Shabbos & Rosh Chodesh
Zman::parse('January 28, 2017')->leiningAt('shacharis') // Vaeira & Rosh Chodesh
Hallel
1 | Zman::parse('April 18, 2017')->hasHallel(); // true - Pesach |
Mussaf
1 | Zman::parse('November 1, 2016')->hasMussaf(); // true - Rosh Chodesh |
Slichos
Besides for checking if a given day has slichos, the first day of slichos for both ashkenazim and sfardim before the Yomim Noraim is available via a helper method.
1 | Zman::firstDayOfSfardiSlichos('5776')->toFormattedDateString(); // Sep 4, 2016 |
The default value for slichos is ashkenazi. To check for sfardi values pass true
as a parameter.