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
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.
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.
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
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:
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');
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:
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:
But there is still more to cover. In upcoming articles, I’ll talk about:
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.