This post continues our exploration of the concepts and techniques involved in calculating the so-called “Jewish years” (zmanim). It also introduces the skills required to use the PHP Zmanim library, a library of functions that makes it easy to calculate Jewish time. Once again, I am indebted to many people, including Eliyahu Hershfeld, the creator of the Kosher Java library, Zachary Weixelbaum (owner of the PHP Zmanim library, a port of Kosher Java), and Elyahu Jacobi (who built royZmanim.com). Maor Neim, who used these tools and patiently explained numerous concepts to me) and provided explanations that turned theory into practice.
introduction
In my last post, I looked at both the basic concepts of Jewish time calculation (zmanim) and the initial steps required to install and use PHP Zmanim. We ended up calculating the sunrise with that library.
On its own, it’s not particularly impressive. In fact, with the same information (latitude, longitude, time zone, and specific date), you can get the same information using functions built into PHP.
In this post we will learn about types of calculations that cannot be achieved with built-in PHP tools. Not only because it requires “interesting” time manipulation, but because there are too many ways to do the same calculation. It is a religiously significant moment based on various rabbinic views and traditions.
The answer to every Jewish question is, “Well, it depends…” It begins with “
Let’s take a moment to unpack that idea in more detail.
In my last post, I started thinking:
Dawn is the moment when light (but not the sun) is visible over the horizon. Unfortunately, whether there is “light” or not is very subjective, so the way it is calculated applies across the map.
- Some traditions use a fixed number of minutes before sunrise or after sunset.
- Others use astronomy to identify times when the sun is below the horizon by a certain angle.
- Others use formulas such as taking the amount of daylight (sunrise to sunset), dividing it into 10 equal parts, and then subtracting that amount from the sunrise or adding it to the sunset.
- Nevertheless, others calculate the difference (in clock minutes) using the time the sun is below the horizon on the “same” day (vertical or autumnal equinox, when the amount of sunlight and darkness is exactly the same). Time and sunrise, normalize that time to the “seasonal time” (“sha’ot zmaniyot”) for that particular day, and finally subtract that time from that day’s sunrise (or add it to sunset).
It’s just one moment of the day, but there are many different ways to decide this.
This may be difficult for people outside of mainstream Orthodox Judaism to understand, and is certainly the topic of a completely different type of blog post. But the answer is to embrace the understanding that all of the above calculations (and many others) are capital-T. “truth”. Not in a “well, it’s true for me depending on how I feel about it” way, but absolutely, factually, empirically true, even when one way is opposed to another way (or several other ways).
As I said, that’s a topic for a whole other blog post.
For now, this is just to explain why Eliyahu Hershfeld, when creating the Kosher Java library, took the route of enabling the ability to easily calculate time using one of these methods, rather than advocating for a single method and coding exclusively for it. mentions . And ports like Zachary Weixelbaum’s PHP Zmanim library continue these ideals.
This brings us back to the point of using the PHP Zmanim library.
make time pretty
In the last post we ended up with the following 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";
?>
The results are as follows:2024-12-20 07:48:52
It works, but it’s not what I want to see on the page when I’m simply expecting “7:48 AM”.
This brings us to the next interesting insight into the PHP Zmanim library. Instead of messing with PHP’s built-in options, you can use other functions to format the output. It still uses PHP time/date formatting code, but it’s easier to achieve what you want.
Let’s say you only want to display hours, minutes, and AM/PM for your sunrise output. Let’s add a line like this:
$sunrise = $zmanim->sunrise;
$sunrise = $sunrise->format('g:i a');
When printed to the screen it looks like this:7:48 am
Getting Your First Real Live – Mincha Gedola
The problem with using sunrise/sunset as an example is that PHP has built-in options that do the same thing. Let us now look at a time more relevant to Jewish religious times: the earliest time for afternoon prayer (Mincha Gedola).
Again, it’s a bit out of context in that it’s a single command.
$gedolah = $zmanim->minchaGedola;
The following times are output:2024-12-20 12:46:55
However, as mentioned earlier in this post, there are several ways to calculate this time. All methods supported by the PHP Zmanim library are:
minchaGedola
: Returns the time 6.5 halachic hours (shaos zmaniyos) after sunrise.minchaGedola30Minutes
: Returns the time 30 standard (clock) minutes after the half-day calculation (chatzot).minchaGedola72Minutes
: According to Magen Avraham (Abraham Abele Gombiner, 1635-1682), the day is calculated to start 72 minutes before sunrise and end 72 minutes after sunset.minchaGedola16Point1Degrees
: According to Magen Avraham, the day begins and ends when the sun is 16.1 degrees below the horizon.minchaGedolaAhavatShalom
: In accordance with the opinion of Rabbi Yaakov Moshe Hillel, the seasonal minutes (shaah) are calculated as 30 minutes (shaah) after noon (chatzos), and the seasonal minutes (shaos zmaniyos) are calculated based on the day starting 72 minutes before sunrise and ending 13.5 minutes after sunset.minchaGedolaGreaterThan30
: This is a convenience method that returns ‘minchaGedola30Minutes’, the latter of the standard “minchaGedola” functions. In winter, when 1/2 the seasonal time (sha’ah) is less than 30 minutes, minchaGedola30Minutes is returned, otherwise the regular minchaGedola is returned.minchaGedolaAteretTorah
: This method returns the time. mincha chain According to Magen Avraham, the day begins and ends when the sun is 16.1 degrees below the horizon.minchaGedolaBaalHatanya
: This calculation is based on comments from Baal Hatanya.minchaGedolaBaalHatanyaGreaterThan30
: This is a convenience method that returns minchaGedolaBaalHatanya or minchaGedola30Minutes, whichever comes later. In winter when 1/2 the seasonal time (sha’ah) is less than 30 minutes, minchaGedola30Minutes is returned, otherwise minchaGedolaBaalHatanya is returned.minchaGedolaGRAFixedLocalChatzos30Minutes
: A method that returns time based on Rav Moshe Feinstein’s comments.
As you can see, there are many different opinions. Deciding which one you want or should use is beyond the scope of this blog post and may require conversation with app or website users and your rabbi. Or two. Or several.
But the good news is that using one of these is as simple as:
$gedolah = $zmanim->minchaGedola16Point1Degrees;
$gedolah = $gedolah->format('g:i a');
Things Get Complicated – Nightfall (Tzais Hakochavim)
Now that you see how we get one, you should understand that even what I previously labeled “complicated” isn’t that complicated. Additionally, tools like PHP Zmanim can help you get the job done in less time, which should strengthen your understanding of how powerful this tool is.
Calculating twilight (tzais hakochavim) is as simple as the following command:$tzais = $zmanim->tzais;
If you’re up for the challenge, there are a ton of variations to consider. I am listing them here without explanation. You only know how many there are. you’re right. There are 32 different options to calculate this once. I have listed them here without detailed explanation just to emphasize my point.
- Zeiss
- tzais72
- tzaisGeonim3Point7 also
- tzaisGeonim3Point8 also
- tzaisGeonim5Point95 degrees
- tzaisGeonim3Point65 degrees
- tzaisGeonim3Point676 degrees
- tzaisGeonim4Point61 degrees
- tzaisGeonim4Point37 degrees
- tzaisGeonim5Point88 degrees
- tzaisGeonim4Point8Degrees
- tzaisGeonim6Point45 degrees
- tzaisGeonim7Point083 also
- tzaisGeonim7Point67 degrees
- tzaisGeonim8Point5 also
- tzaisGeonim9Point3 also
- tzaisGeonim9Point75 degrees
- tzais60
- tzaisAteretTorah
- tzais72Zmanis
- tzais90Zmanis
- tzais96Zmanis
- tzais90
- tzais120
- tzais120Zmanis
- tzais16Point1 also
- 26 degrees
- tzais18 degrees
- tzais19 points 8 degrees
- tzais96
- tzaisBaalHatanya
- tzais50
Time (and this blog series) continues
Building on the information in this post, looking at the main README on Zachary’s PHP Zmanim page itself, and choosing the best (suitable for your purposes) calculations for the following items, you can make significant progress.
- Sunrise and Sunset (No, don’t sing that song)
- “Seasonal” times (Shaa Zma’s)
- dawn (also hashachar)
- Earliest time to wear tallit and tefillin (misheyakir)
- The latest time to say Shema (Sof zman kria shema)
- Last hour of morning prayer (sof zman tefillah)
- When Passover begins
- middle of the day (chatzos)
- The earliest time for afternoon prayer (mincha gedola)
- The “best” time for afternoon prayer (Mincha Ketana)
- Last hour of afternoon prayer (Plague Hamincha)
- Sabbath candle lighting time
- Dusk – The time between sunset and night (Bain Hashmashot).
- Chestnut (tzais hakochavim)
- About halfway through the night (chatozs halayla)
But there’s still more to cover. In the next article we will talk about:
- We take these standard times and adjust them to suit the needs of each synagogue (“Mincha begins 25 minutes before Shkia each day”).
- Uses the PHP Zmanim library to display non-hourly calculations such as weekly Torah Portion, Rosh Chodesh and Molad.
- It leverages built-in astronomy functions for time calculations that are not built into the library itself.
I hope you continue this journey with me. As always, if you have any questions, comments, or compliments, please leave them in the comments.