Acknowledgments
This post continues my exploration of concepts and techniques related to both the way so-called âJewish timesâ (zmanim) are calculated; as well as the techniques needed to use theÂ
Once again, I owe a huge debt of gratitude to several folks â including Eliyahu Hershfeld, creator of theÂ
Introduction
In my last post, I explored both the foundational concepts of Jewish time calculations (zmanim) and also the initial steps needed to install and use PHP Zmanim. We got as far as calculating sunrise with that library.
By itself, this isnât particularly impressive. The fact is that with the same information (latitude, longitude, time zone, and a specific date) you can get the same information using PHPâs built-in functions.
In this post, weâre going to get into the types of calculations you CANâT get with built-in PHP tools, not only because they require some âinterestingâ time manipulations, but because there are so many ways to calculate the same religiously significant moment, based on various Rabbinic opinions and traditions.
The Answer to Every Jewish Question Starts With âWell, It DependsâŚâ
Let me take a minute to unpack that idea in a little more detail.
In the last post, I started to get into this idea:
Dawn is the moment when light (but not the sun) is visible over the horizon. Unfortunately, whether or not there is or isnât âlightâ is highly subjective, and therefore the way itâs come to be calculated ranges all over the map.
Some traditions use a fixed number of clock minutes before sunrise or after sunset.
Others will use astronomy to identify the time when the sun is below the horizon by a specific number of degrees.
Others will use a formula, such as taking the amount of daylight (from sunrise to sunset), dividing that into 10 equal parts, and then subtracting that amount from sunrise or adding it to sunset.
Still others will take the time the sun is below the horizon on an âequalâ day (meaning the spring or fall equinox, when the amount of sunshine and darkness are exactly the same), calculate the difference (in clock minutes) between that time and sunrise, normalize those minutes against âseasonal minutesâ (âshaâot zmaniyotâ) for the specific day in question, and finally subtract that amount from sunrise (or add THAT to sunset) for the day in question.
One moment of the day, but a wide variety of ways to determine it.
It may be hard for those outside of mainstream orthodox Judaism to understand and is definitely the subject of a completely different type of blog post, but the answer is to embrace the understanding that all of the calculations above (and many others) are capital-T âTrue.â
Not just in a âwell, itâs how I feel about it so itâs true to meâ kind of way, but as being absolutely, factually, empirically true even when one method stands in opposition to another (or several others).
Like I said, THAT is the topic of a completely different blog post.
For now, I mention this to explain why, in creating the Kosher Java library, Eliyahu Hershfeld took the route of enabling the ability to easily calculate times using ANY of those methods, rather than trying to espouse a single method and coding exclusively for that.
And ports â such as Zachary Weixelbaumâs PHP Zmanim library â simply continue with that ideal.
Which brings us back to the nitty-gritty of using the PHP Zmanim library.
Making Time Pretty
In the last post, we left off with this snippet of code:
<?php
require 'vendor/autoload.php';
use PhpZmanim\Zmanim;
use PhpZmanim\Calendar\ComplexZmanimCalendar;
use PhpZmanim\Geo\GeoLocation;
# Set variables:
#41.4939407, -81.516709;
$locname = "Beit Knesset Chochmat Shlomo, Beachwood, OH";
$lat = 41.4939407;
$long = -81.516709;
$elev = 0;
$tz = 'America/New_York';
$getyear = 2024;
$getday = 20;
$getmonth = 12;
$testzmanim = Zmanim::create($getyear, $getmonth, $getday, $locname, $lat, $long, $elev, $tz);
$sunrise = $testzmanim->sunrise;
echo "$sunrise\n";
?>
Which produced a result that looked something like this:2024-12-20 07:48:52
It works, but itâs not what Iâd want to see on a page when Iâm just expecting a simple â7:48 amâ.
Which brings me to the next interesting insight for the PHP Zmanim library: You can format the output using another function, rather than hammering through PHPâs built-in options. Youâll still use the PHP time/date formatting codes but getting what you want is easier.
Letâs say I want to only display the hour, minute, and am/pm for the sunrise output. Iâd add a line like this:
$sunrise = $zmanim->sunrise;
$sunrise = $sunrise->format('g:i a');
Which would look like this when printed on the screen:7:48 am
Getting Your First Actual real-time â Mincha Gedola
The problem with using sunrise/sunset as an example is that PHP has built-in options to do the exact same thing. So, letâs look at getting a time that is more relevant to Jewish religious times: the earliest time for afternoon prayers (Mincha Gedola).
Once again, itâs somewhat anti-climactic in that itâs a single command:
$gedolah = $zmanim->minchaGedola;
Which outputs a time like this:2024-12-20 12:46:55
HOWEVER, as I mentioned earlier in this post, there are several ways to calculate this time. Here are all the methods supported by the PHP Zmanim library:
- minchaGedola: Returns a time of 6.5 halachic hours (shaos zmaniyos) after sunrise.
- minchaGedola30Minutes: Returns the time 30 standard (clock) minutes after the half-day calculation (chatzot).
- minchaGedola72Minutes: Calculates according to the Magen Avraham (Abraham Abele Gombiner, 1635-1682) with the day starting 72 minutes before sunrise and ending 72 minutes after sunset.
- minchaGedola16Point1Degrees: Calculated according to the Magen Avraham with the day starting and ending when the sun is 16.1 degrees below the horizon.
- minchaGedolaAhavatShalom: Calculated based on the opinion of Rabbi Yaakov Moshe Hillel as half a seasonal hour (shaah) after mid-day (chatzos) with seasonal minutes (shaos zmaniyos) calculated based on a day starting 72 minutes before sunrise and ending 13.5 minutes after sunset.
- minchaGedolaGreaterThan30: This is a convenience method that returns the later of the standard âminchaGedolaâ function or âminchaGedola30Minutes. In the winter when 1/2 of a seasonal hour (shaâah) is less than 30 minutes, then minchaGedola30Minutes will be returned, otherwise, the regular minchaGedola will be returned.
- minchaGedolaAteretTorah: This method returns the time of mincha ketana according to the Magen Avraham with the day starting and ending when the sun is 16.1 degrees below the horizon.
- minchaGedolaBaalHatanya: This calculation is based on the opinion of the Baal Hatanya.
- minchaGedolaBaalHatanyaGreaterThan30: This is a convenience method that returns the later of either minchaGedolaBaalHatanya or minchaGedola30Minutes. In the winter when 1/2 of a seasonal hour (shaâah) is less than 30 minutes, then minchaGedola30Minutes will be returned, otherwise minchaGedolaBaalHatanya will be returned.
- minchaGedolaGRAFixedLocalChatzos30Minutes: This method returns a time based on Rav Moshe Feinsteinâs opinion.
As you can see, there are a number of opinions. Determining which one you want/need to use is outside the scope of this blog post and will likely require some conversations with the users of the app or website, as well as a Rabbi. Or two. Or several.
But the good news is that to use any of them, itâs as simple as:
$gedolah = $zmanim->minchaGedola16Point1Degrees;
$gedolah = $gedolah->format('g:i a');
Getting Something Complicated â Nightfall (Tzais Hakochavim)
Now that youâve seen how we get one time, you should understand that even times that my previous post labeled as âcomplicatedâ arenât that complicated. Furthermore, it should reinforce your understanding of just how powerful a tool like PHP Zmanim is because of what it enables you to do in such a short time.
Calculating nightfall (tzais hakochavim) is as simple as the command$tzais = $zmanim->tzais;
If there is any challenge at all, itâs the sheer number of variations to consider. Iâm listing them here without explanation, just so you have a sense of how many there are. Thatâs right, there are 32 different options for calculating this one time. I list them here without detailed explanation simply to underscore my point:
- tzais
- tzais72
- tzaisGeonim3Point7Degrees
- tzaisGeonim3Point8Degrees
- tzaisGeonim5Point95Degrees
- tzaisGeonim3Point65Degrees
- tzaisGeonim3Point676Degrees
- tzaisGeonim4Point61Degrees
- tzaisGeonim4Point37Degrees
- tzaisGeonim5Point88Degrees
- tzaisGeonim4Point8Degrees
- tzaisGeonim6Point45Degrees
- tzaisGeonim7Point083Degrees
- tzaisGeonim7Point67Degrees
- tzaisGeonim8Point5Degrees
- tzaisGeonim9Point3Degrees
- tzaisGeonim9Point75Degrees
- tzais60
- tzaisAteretTorah
- tzais72Zmanis
- tzais90Zmanis
- tzais96Zmanis
- tzais90
- tzais120
- tzais120Zmanis
- tzais16Point1Degrees
- tzais26Degrees
- tzais18Degrees
- tzais19Point8Degrees
- tzais96
- tzaisBaalHatanya
- tzais50
Time (and This Blog Series) Marches On
Armed with the information in this post, you could probably make decent headway simply by looking through the main README on Zacharyâs PHP Zmanim page itself, and selecting the best (for your purposes) calculations for:
- Sunrise and Sunset (no, do not sing That Song)
- A âseasonalâ hour (Shaâah Zmanim)
- Dawn (alos hashachar)
- The earliest time to put on tallit and tefillin (misheyakir)
- The latest time to say Shema (sof zman kria shema)
- The latest time for morning prayers (sof zman tefillah)
- When Passover begins
- Halfway through the day (chatzos)
- The earliest time for afternoon prayers (mincha gedola)
- The âbestâ time for afternoon prayers (mincha ketana)
- The latest time for afternoon prayers (plag hamincha)
- The time to light Shabbat candles
- Dusk â the time between sunset and night (bain hashmashot)
- Night (tzais hakochavim)
- Halfway through the night (chatozs halayla)
But there is still more to cover. In upcoming articles, Iâll talk about:
- Taking these standard times and adjusting them for synagogue specific needs (âMincha starts 25 minutes before Shkia each dayâ).
- Using the PHP Zmanim library to display non-time calculations such as the weekly Torah Portion, Rosh Chodesh, and the Molad.
- Leveraging the build-in astronomy functions for time calculations that arenât built into the library itself.
I hope youâll continue on this journey with me. As always if you have questions, comments, or kudos, please leave them in the comments.