This post continues my exploration of concepts and techniques related to how the so-called “Jewish times” (zmanim) are calculated; as well as the techniques needed to use the PHP Zmanim library – a library of functions that allow you to easily calculate Jewish times. Once again, I owe a lot of thanks to several people – including Eliyahu Hershfeld, creator of the Kosher Java library, Zachary Weixelbaum (owner of the PHP Zmanim library, a port of Kosher Java), Elyahu Jacobi (who built RoyZmanim.com with that tool and patiently explained so many concepts to me), and Maor Neim, who offered explanations that turned theory into practice.
Introduction
In my last post I explored both the basic concepts of Jewish time calculation (zmanim) and also the initial steps required to install and use PHP Zmanim. We went as far as calculating sunrise with that library.
By itself, this is not particularly impressive. The fact is that with the same information (latitude, longitude, time zone and specific date) you can get the same information using PHP built-in functions.
In this post, we will address the kinds of calculations you CANNOT get with the built-in PHP tools, not only because they require some “interesting” time manipulation, but because there are so many ways to calculate the same religiously significant moment, based on different rabbinical opinions and traditions .
The answer to every Jewish question begins 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 above the horizon. Unfortunately, whether or not there is “light” is very subjective, so the way it’s calculated is spread all over the map.
- Some traditions use a fixed number of minutes on the clock before sunrise or after sunset.
- Others will use astronomy to determine the time when the sun is a certain number of degrees below the horizon.
- 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 when the sun is below the horizon on an “equinox” day (which means the spring or autumn equinox, when the amount of sun and darkness is exactly the same), calculate the difference (in minutes of an hour) between that time and sunrise, normalize that minutes against the “seasonal minutes” (“sha’ot zmaniyot”) for the particular day in question, and finally subtract that amount from sunrise (or add THAT to sunset) for the day in question.
One moment in a day, but a wide variety of ways to determine it.
This may be difficult for those outside of orthodox Judaism to understand and is definitely a topic for an entirely different type of blog post, but the answer is to accept the understanding that all of the above calculations (and many others) are capitalized “True”. Not just in a “well, I feel it so it’s true to me” way, but as absolutely, factually, empirically true even when one method contradicts another (or several others).
Like I said, THAT is a topic for a whole other blog post.
For now, I mention this to explain why, in creating the Kosher Java library, Eliyahu Hershfeld went down the path of making it possible to easily calculate time using ANY of those methods, rather than trying to accept one method and code exclusively for it. And ports—like Zachary Weixelbaum’s PHP Zmanim library—simply continue that ideal.
This brings us back to the nitty-gritty of using the PHP Zmanim library.
Beautifying the weather
In the last post we stopped with this code snippet:
<?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 like to see on the page when I expect a simple “7:48am”.
This brings me to the next interesting insight into the PHP Zmanim library: you can format the output using another function, instead of fumbling through PHP’s built-in options. You will still use PHP codes to format the time/date, but it will be easier to get what you want.
Let’s say I want to display only the hour, minute and AM/PM for the sunrise output. I would add a line like this:
$sunrise = $zmanim->sunrise;
$sunrise = $sunrise->format('g:i a');
What it would look like when printed on the screen:7:48 am
Getting Your First Real Real Time – Minch Gedol
The problem with using sunrise/sunset as an example is that PHP has built-in options to do exactly the same thing. So let’s look at how to find a time that is more relevant to Jewish religious times: the earliest time for afternoon prayer (Mincha Gedola).
Once again, it’s somewhat anticlimactic because it’s a single command:
$gedolah = $zmanim->minchaGedola;
Which gives 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 the time of 6.5 halachic hours (shaos zmaniyos) after sunrise.minchaGedola30Minutes
: Returns the time 30 standard (hour) minutes after half-day calculation (chatzot).minchaGedola72Minutes
: Calculated according to Magen Avraham (Abraham Abele Gombiner, 1635-1682) with the day beginning 72 minutes before sunrise and ending 72 minutes after sunset.minchaGedola16Point1Degrees
: Calculated according to Magen Avraham with the day beginning and ending when the sun is 16.1 degrees below the horizon.minchaGedolaAhavatShalom
: Calculated based on Rabbi Yaakov Moshe Hillel’s opinion as half a seasonal hour (shaah) after midday (chatzos) with seasonal minutes (shaos zmaniyos) calculated based on a day beginning 72 minutes before sunrise and ending 13.5 minutes after sunset.minchaGedolaGreaterThan30
: This is a convenience method that returns later than the standard “minchaGedola” or “minchaGedola30Minutes” function. In winter when 1/2 of the seasonal hour (sha’ah) is less than 30 minutes, then the minchaGedola30Minutes will return, otherwise the regular minchaGedola will return.minchaGedolaAteretTorah
: This method returns the time mincha chain according to Magen Avraham with the day beginning and ending when the sun is 16.1 degrees below the horizon.minchaGedolaBaalHatanya
: This calculation is based on the opinion of Baal HatanyminchaGedolaBaalHatanyaGreaterThan30
: This is a handy method that returns minchaGedolaBaalHatanya or minchaGedola30Minutes later. In winter when 1/2 of the season hour (sha’ah) is less than 30 minutes, then minchaGedola30Minutes will return, otherwise minchaGedolaBaalHatanya will return.minchaGedolaGRAFixedLocalChatzos30Minutes
: This method restores time based on the opinion of Rav Moshe Feinstein.
As you can see, there are a range of opinions. Determining which one you want/should use is beyond the scope of this blog post and will likely require some conversations with users of the app or website, as well as the rabbi. Or two. Or several.
But the good news is that using any of them is 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 realize that the times that my previous post labeled as “complicated” aren’t that complicated either. Furthermore, it should reinforce your understanding of how powerful a tool like PHP Zmanim is, because of what it allows you to do in such a short amount of time.
Calculating the night (tzais hakochavim) is as simple as a command$tzais = $zmanim->tzais;
If there’s any challenge at all, it’s the sheer number of variations to consider. I list them here without explanation, just to give you a sense of how many there are. That’s right, there are 32 different options for calculating this moment. I list them here without detailed explanation just to make 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
- tzais 26 degrees
- tzais 18 degrees
- tzais19Point8Degrees
- tzais96
- tzaisBaalHatanya
- tzais50
Time (and this blog series) moves on
Armed with the information in this post, you could probably make decent progress by simply going through the main README on Zachary’s PHP Zman page and picking the best (for your needs) calculations for:
- Sunrise and sunset (no, don’t sing that song)
- “Seasonal” Hour (Sha’ah Zmanim)
- Dawn (alos hashachar)
- Earliest time to put tallit and tefillin (misheyakir)
- The latest time to say Shema (sof zman kria shema)
- Latest time for Fajr prayer (sof zman tefillah)
- When Pesach begins
- Half day (chatzos)
- The earliest time for afternoon prayer (mincha gedola)
- The “best” time for afternoon prayer (mincha ketana)
- The latest time for afternoon prayer (plag hamincha)
- Time to light Shabbat candles
- Dusk – the time between sunset and night (bain hashmashot)
- Night (tzais hakochavim)
- Half the night (chatozs halayla)
But there is more to cover. In the upcoming articles I will talk about:
- Taking these standard times and adapting them to the specific needs of the synagogue (“Mincha begins 25 minutes before Shki each day”).
- Using the Zmanim PHP library to display non-temporal calculations such as the weekly Torah portion, Rosh Chodesh, and Molad.
- Taking advantage of the built-in astronomical functions for time calculations that are not built into the library itself.
I hope you will continue this journey with me. As always, if you have any questions, comments, or compliments, please leave them in the comments.