◆ How Zmanim Are Calculated
This page documents the exact algorithms and halachic opinions used by ZmanimPro. All calculations are performed by the open-source PhpZmanim library (LGPL-2.1), a PHP port of Eliyahu Hershfeld's KosherJava API.
1. Solar Position (Sunrise & Sunset)
Sunrise and sunset are computed using the NOAA Solar Calculator, based on Jean Meeus' Astronomical Algorithms (2nd edition, Willmann-Bell, 1998). The key formula:
cos(H) = (sin(h₀) − sin(φ)·sin(δ)) / (cos(φ)·cos(δ))
Where:
H= hour angle of the sunh₀= altitude of the sun's center = −0.833° (for sunrise/sunset)φ= observer's latitudeδ= solar declination
The value −0.833° accounts for:
- 34′ atmospheric refraction (light bends as it passes through the atmosphere, so the sun appears higher than it actually is)
- 16′ solar radius (we measure when the upper limb of the sun appears, not its center)
Accuracy: ±0.01° in solar position, corresponding to roughly ±1 minute of time at mid-latitudes.
2. Halachic Hours (Sha'ot Zmaniyot)
Jewish law divides daylight into 12 equal "halachic hours." There are two primary opinions on what counts as "daylight":
| Opinion | Day starts | Day ends | Used by |
|---|---|---|---|
| GRA (Vilna Gaon) | Sunrise (netz) | Sunset (shkiah) | Most Ashkenazi & Sephardi communities today |
| Magen Avraham | Dawn (alot haShachar, 72 min before sunrise) | Nightfall (tzait haKochavim, 72 min after sunset) | Some Hasidic & Sephardi communities |
A halachic hour under the GRA = (sunset − sunrise) ÷ 12. We display GRA times by default; Magen Avraham times are available on request via the API.
3. Key Zmanim Formulas
| Zman | Definition (GRA) |
|---|---|
| Alot HaShachar | Sun 72° below horizon (some say 16.1°) |
| Misheyakir | Sun 11.5° (or 10.2°) below horizon |
| Sof Zman Shema | 3 halachic hours after sunrise |
| Sof Zman Tefillah | 4 halachic hours after sunrise |
| Chatzos (midday) | 6 halachic hours after sunrise = (sunrise + sunset) ÷ 2 |
| Mincha Gedola | 6.5 halachic hours after sunrise |
| Mincha Ketana | 9.5 halachic hours after sunrise |
| Plag HaMincha | 10.75 halachic hours after sunrise |
| Shkiah (sunset) | Sun's upper limb below horizon |
| Tzait HaKochavim (8.5° GRA) | Sun 8.5° below horizon (~36 min at equinox) — standard Tzait HaKochavim |
| Tzait HaKochavim (72 min) | 72 fixed minutes after sunset (Rabbeinu Tam simplified) |
| Tzait HaKochavim (16.1° Rabbeinu Tam) | Sun 16.1° below horizon (~72 min at equinox) — Rabbeinu Tam degrees opinion |
4. Candle Lighting Time
Candle lighting marks the acceptance of Shabbat. The time is computed as sunset − candle offset:
| City | Offset | Basis |
|---|---|---|
| Jerusalem | 40 minutes | Yereim (Rabbeinu Elchanan); also accounts for 825m elevation |
| Most communities | 18 minutes | Widely adopted Roman/Pest custom |
| Some communities | 20, 22, or 30 minutes | Local communal custom (minhag) |
5. Havdalah (End of Shabbat)
Havdalah is recited at nightfall (tzait haKochavim), when three medium-sized stars are visible. We display the 72-minute opinion (Rabbeinu Tam simplified) by default, and also show 8.5° (GRA) (~36 min at equinox, the standard Tzait HaKochavim) and 16.1° (Rabbeinu Tam degrees) (~72 min at equinox) times.
Rabbeinu Tam (a more stringent opinion) defines nightfall as 4 mil after sunset. This is calculated either as fixed 72 minutes (4 × 18 min/mil) or astronomically as 16.1° below the horizon. Many observant individuals wait for this time before performing melacha (work forbidden on Shabbat), as a stringency (lechumra).
6. Hebrew Calendar Algorithm
The Hebrew calendar is computed by the algorithm described by Maimonides in Hilchot Kiddush HaChodesh (12th century) and refined by Gauss (1802). Key rules:
- Months alternate 29 and 30 days (defective vs. full months).
- Leap years (with Adar II added) occur in years 3, 6, 8, 11, 14, 17, 19 of a 19-year cycle.
- Molad (mean lunar conjunction) is computed; Rosh Hashana is postponed by 4 rules (Dehiyot) to prevent Yom Kippur from falling adjacent to Shabbat, etc.
This is implemented in PhpZmanim's JewishCalendar class, which we use for all Hebrew-date conversions on this site.
7. Sources of Variation
Minor differences (1–2 minutes) can occur between Zmanim calculators due to several methodological factors. Understanding these helps explain why times may differ slightly from one source to another:
- Solar calculator: Different implementations use NOAA, Jean Meeus, or the higher-precision Solar Position Algorithm (SPA). We use the NOAA calculator by default.
- Elevation data: Altitude affects sunrise/sunset by roughly 1 minute per 1,500 meters. Sources using different elevation models will produce slightly different times.
- Rounding conventions: Some sources round to the nearest minute; others truncate. We round to the nearest minute.
- Halachic opinions: The choice between 8.5° and 72 minutes for nightfall, or between GRA and Magen Avraham for halachic hours, produces different Zmanim. We display both opinions where relevant.
PhpZmanim supports multiple calculators (NoaaCalculator, SunTimesCalculator, ZmanimCalculator), allowing users to select the precision level they need. Our default configuration uses the NOAA calculator, which balances accuracy and computational efficiency.
Frequently Asked Questions
What algorithm does ZmanimPro use to calculate sunrise and sunset?
We use the NOAA Solar Calculator, based on Jean Meeus' "Astronomical Algorithms" (2nd edition, 1998). The formula computes the sun's declination and hour angle, then applies the standard altitude of -0.833° (the sun's upper limb appears on the horizon, accounting for 34' atmospheric refraction and 16' solar radius).
Why is candle lighting 18 minutes before sunset in most cities?
The 18-minute custom (Roman/Pest) is a widely adopted stringency to ensure candles are lit before Shabbat begins. Some communities use 20, 22, or 30 minutes. Jerusalem uses 40 minutes, based on the Yereim and the city's elevation.
What is tzait haKochavim (nightfall)?
Tzait haKochavim is when three medium-sized stars are visible, marking the end of Shabbat and holidays. The GRA opinion calculates this as the sun being 8.5° below the horizon. The 72-minute opinion is also widely used.
How accurate are the calculations?
The NOAA algorithm is accurate to ±0.01° in solar position, corresponding to roughly ±1 minute of time at most latitudes. Elevation and atmospheric conditions can introduce small variations.