ZIP Codes and Zmanim – Use With Care

99557 ZIP code - the largest in the USA
The 99557 ZIP code in Alaska – the largest in the USA
There are many zmanim services and apps that use ZIP codes as a location finder for calculating zmanim. While very convenient, there is a potential pitfall in using ZIP codes for geolocation. In general, ZIP code geolocation services will provide the center of the ZIP code and zmanim apps calculate zmanim for that location. The issue arises with large ZIP code areas mostly found in rural areas. Take the following two extreme cases that have very large ZIP code areas. ZIP code 89049 for rural Tonopah, NV, is 195 km (121 mi) from east to west. The eastern boundary of this non-contiguous ZIP code has a longitude of -115.417°, while the western boundary is -117.625°. This means that there are 2.2° of longitude between the eastern and western borders of this ZIP code. The earth rotates 1 degree every 4 minutes, so zmanim at the eastern and western edges of this ZIP code are approximately 8.8 minutes apart. Using the typical center of the ZIP based calculations would mean that zmanim would be about 4.4 minutes different at the edges compared to the center. Moving to something a bit more extreme, is the case of ZIP code 99557 of Aniak, Alaska and its surrounding area. This ZIP code is 415 km (258 mi) from east to west. The longitude of the eastern edge of the ZIP code is -153.032°, and the western edge is -160.783°. Being farther north and therefore having shorter distances between degrees of longitude, this ZIP code stretches across 7.7° of longitude. The zmanim difference from the center to the edges of this ZIP code is 15 and a half minutes (31 minutes across the ZIP). While it is indeed rare to have such large distances, there are 193 US ZIP codes that are over 1° of longitude wide, meaning that the zmanim difference for these ZIP codes are at a minimum 4 minutes apart, or 2 minutes off from the center. There are 1,463 or 4.4% of all ZIP codes with 0.5° or greater distance between east and west (a minimum of a 2 minute zmanim difference between the east and west zide of the ZIP code). zmanim software developers should be aware of this, and take care to alert users of possible inaccuracies when using large ZIP code areas, or require addresses or more specific location information for large zip codes.
Let’s contrast the above with Lakewood, NJ. With 0.107° of longitude from east to west, zmanim are 24 seconds later on the west side (the intersection of New Central Ave & N Hope Chapel Rd) than the east side (Shinn Cranes, 1600 Ocean Ave).
See the Calculation of Zmanim VS Other Sites post for additional related material.
I thank Avraham David Gelbfish for generating the ZIP code longitude range for all 33,093 ZIP codes from the US Census Bureau ZIP code shape files.

The Novaya Zemlya Effect’s Impact on Zmanim

Novaya Zemlya Effect Distorted Sun
A Distorted Sun Caused by the Novaya Zemlya Effect (Credit: Brocken Inaglory)
You may have seen disclaimers on zmanim calendars warning of up to a 2 minute inaccuracy due to weather and atmospheric conditions. Atmospheric refraction from the earth’s atmosphere, causes the sun to be visible on average about 3 minutes earlier at sunrise, and about 3 minutes later at sunset (compared to a vacuum) due to the atmosphere bending the sunlight upwards towards the viewer. The 3 minutes is only an average, and it can swing widely due to weather and atmospheric conditions. The typical variance caused by “non-average” atmospheric conditions would usually be within 2 minutes, resulting in the 2 minutes mentioned in the disclaimers. This 2 minute variance is during usual conditions, though there are conditions that would greatly increase this time.

Refraction Explained

Refraction at Sunset
Refraction at Sunset
When the sun’s rays traveling through the vacuum of space hit the earth atmosphere, they slow down and bend upwards towards the observer resulting in the sun being visible earlier (than in a vacuum) in the morning, and later at sunset.
Straw appearing to be bent due to refraction
Straw appearing to be bent due to refraction
Refraction of the sun’s rays is not a one stage refraction, but as the sun passes through increasingly dense layers of atmosphere, the amount of refraction increases with each thicker layer. This can be seen in the diagram of refraction at sunset above. The apparent position of the sun near sunset in the image (exaggerated in the image) is height of the sun as it appears to the user, though in reality the sun is below the horizon. Refraction can easily be observed by looking at a straw in a partially filled glass. The straw appears to bend (or be broken) at the point it enters the water. This is due to increased refraction in water versus air.

Complexity in Calculating Refraction

Since the amount of refraction depends on the pressure (the more dense the atmosphere is, the greater the refraction), temperature (hot air is less dense and refracts less) and to a lesser degree humidity (water vapor in the air impacts the refraction) in each layer of the atmosphere, calculating refraction is complex and requires very detailed meteorological information on the current conditions in each layer of the atmosphere in the area being computed. This can’t be done accurately in advance, and even calculations for the current day require readings from weather balloons at multiple elevations for accurate measurement, something not very practical (though the Lakewood vasikin minyan (likely done elsewhere as well) manually adjusts the hanetz hachama time each morning based on the weather). For this reason, zmanim (as well as civil sunrise and sunset) calculations usually use a global average refraction of 34′ of a degree, or 0.5666°. The global average atmospheric refraction accounts for sunrise being between 3:01 minutes earlier (during the solstice), and 2:29 minutes earlier (during the equinox) in Yerushalayim, as opposed to the value in a vacuum (the difference depends on where in the world you are, in Lakewood, NJ the range is 3:29 – 2:57). This average atmospheric refraction is not very accurate but is commonly used since it is complex to calculate local averages. More accurate refraction figures can be calculated for local and seasonal atmospheric models, and these have been shown to be accurate to within 15 seconds 90% of the time in the case of summer and winter subtropical models used in a study in Israel. See Using a Digital Terrain Model to Calculate Visual Sunrise and Sunset Times by Rabbi Chaim Keller and Dr. John K. Hall for additional details.

Inversion and the Novaya Zemlya Effect

Under usual conditions, the atmosphere gets colder at elevation, with the warmest air being closest to earth. An inversion condition is where there is a layer of cold air under a layer of warmer air. When there is an inversion over a large area (greater than 400 km), the solar rays get ducted in the lower colder air layer (see image below) and produce an extreme refraction. This is known as the Novaya Zemlya effect and produces a solar mirage resulting in the somewhat visually distorted sun being visible much earlier than expected (see top image).

Novaya Zemlya Effect Refraction Diagram (Credit: W. H. Lehn)
Novaya Zemlya Effect Refraction Diagram
While typically a phenomena in the polar regions, a study by the University of Calgary showed that refraction can have a significant affect on zmanim even in non-polar areas. In the 2003 study (Variability in the Astronomical Refraction of the Rising and Setting Sun), they observed that the sunrise on January 10, 1991 appeared almost 12 minutes earlier than expected. The paper mentions:

On rare occasions, the Sun appeared to rise much earlier or set much later than predicted by such publications as the Tables of Sunrise, Sunset, and Twilight (USNO 1962). In our study, the sunrise of 1991 January 10 was almost 12 minutes early. This phenomenon is known as the Novaya Zemlya solar mirage (Lehn 1979). It appears to be caused by a geographically extensive temperature inversion within the boundary layer of the atmosphere. The resulting vertical density profile causes the sunlight to be ducted around the curvature of the Earth. For the purpose of this study, we defined anomalously large astronomical refraction to be an event with refraction greater than 1°. A total of 12 anomalous events were recorded (2.9%).

While these typically occur in cold areas, they can happen in other areas as well. The study authors mention that

The majority of the anomalous events took place in the cold months. Nine of the 12 events occurred between November 1 and April 30, with January having five events. At the time of the events, the average surface temperature was -10.9°C, and all events occurred with surface-inversion conditions. Surface inversions tend to form with overnight surface radiative cooling through a dry atmosphere. Typically, they persist into the early morning, even after sunrise. Even though most of the events took place in the cold parts of the year, the data suggest that the Novaya Zemlya solar mirage may not be an exclusively cold-weather or polar phenomenon. Four of the events occurred with a surface temperature greater than 0°C. One event took place 2 days after the summer solstice.

Refraction at Sunrise VS Sunset

The University of Calgary study found that extreme refraction is an order of magnitude more common at sunrise than sunset. The reason for the difference between sunrise and sunset is that

This may be because the lower atmosphere is better mixed during the day as a result of solar heating leading to a dry adiabatic lapse rate in the boundary layer. Anomalously large astronomical refraction events the “Novaya Zemlya solar mirage” occurred about 3% of the time and were an order of magnitude more common at sunrise than sunset.

That said, The Novaya Zemlya effect does occur at sunset and in warm climates as seen in this video of sunset taken in San Francisco. Sadly, the video does not include information on how long it delayed sunset.


Halachically sunrise and sunset times depend on when we can see the sun, and not when it is at the horizon. As mentioned above, the average global refraction of 34′ results in sunrise appearing about 3 minutes earlier and sunset 3 minutes later later than in a vacuum, and this refraction (or other similar refraction values) is what is used in all calendars (both halachic and civil). The fact that there is such potential for variation in weather conditions, and that the global average is likely not what is present where the zmanim are being calculated, is the reason that many luchos (zmanim calendars) have disclaimers about accuracy. Many calendars round off their zmanim without showing seconds due to the inability to accurately calculate zmanim because of refraction variations. Lahalacha the impact of earlier or later sunrise is limited to vasikin minyanim. A separate article may be needed to actually discuss sof zman krias shema and other zmanim’s relation to sunrise and sunset VS the actual position of the sun in the sky (1/4 of the way across its path for sof zman krias shema). The halachic impact of refraction at sunset is much greater since it impacts the day/night boundary, but those are much rarer.
Now to the big question, does extreme refraction such as the Novaya Zemlya effect impact zmanim? The fact that it rarely impacts sunset, means that it almost academic since predicting the inversion before a vasikin minyan starts is impractical. In a conversation with one posek a number of years ago, he felt that the Novaya Zemlya Effect should not impact zmanim lahalacha due to the fact that unusual occurrences should not be factored in, and because the distorted sun is not considered the sun as far as zmanim. I would appreciate being notified if anyone receives a psak halacha on this question.

FAQ: How do I Calculate the Jewish/Hebrew Date for …?

Java Calendar

This FAQ is now obsolete. Jewish Calendar Calculations are now supported. See the Zmanim API 1.3.0 Release announcement


How do I get the Jewish Date for … using the Zmanim API?


The current version of the Zanim API does not support Jewish calendrical calculations. Zmanim are almost exclusively based on the solar calendar, so for example, the sunrise on February 8th this year in Montreal (or any other date and location), will be almost the same every year. for this reason there was little point (as far as zmanim) to support Jewish date calculations in the API. One of the only zmanim to rely on a Jewish date is the sof zman kidush levanah calculation, though there are some opinions that it is purely molad based, and this can be calculated without a Jewish calendar component to the API. This zman is obviously not currently implemented in the Zmanim API. I am currently working on adding Jewish date support to the API. The code is based off Avrom Finkelstein‘s no longer active HebrewDate project. I refactored a lot of the code and fixed a number of bugs. Anyone interested in alpha testing this code can download the latest Zmanim SVN code (or download the Zmanim API 1.3.0 alpha release).
I mentioned that it “will be almost the same every year” and this is due the the approximate 1/4 day drift between the 356 day calendar year and the approximately 365.25 days actually present in the astronomical year, a discrepancy corrected every leap year. A future FAQ (probably a few of them) may delve specifically into this drift as well as general zmanim accuracy issues in detail.
If you are simply looking to convert a Hebrew date to Gregorian or Gregorian to Hebrew online without the API, try the JewishGen calendar conversion tools.

Zmanim Bug Report from the Land of the Midnight Sun

Midnight SunI was recently contacted by Jan Terje Johansen, a developer at Datek Wireless AS in Norway, with an interesting bug report. Datek uses the Zmanim API (the AstronomicalCalendar base class) to allow their clients (the power company and stadiums) to remotely (via a web interface) control streetlights and stadium lights throughout Norway using a wireless lighting control system that they developed. The zmanim code is used to allow setting the lighting times based on an offset of sunrise/sunset. For the technically curious, they are controlled primarily through GPRS, with SMS as fallback. A version under development uses ZigBee. The bug encountered was that for Tromsoe (Tromsø), Norway, as well as other areas within the Arctic Circle that experience the midnight sun, from May 13th to May 17th (the date of last rise of the season in Tromsoe), the zmanim API produced correct sunrise/set times, but the date component (The API returns all times as Java Dates, something that might change with v2.0 of the API that will target JDK 7 to take advantage of JSR-310 Date and Time API) was a day off. For non-automated systems, the date component is not important, but in their case it would cause the lights to go on/off on the wrong day. Jan provided a suggested patch that worked well. The actual fix I used was slightly different because I took advantage of the time spent on fixing the bug to refactor and simplify the code. This change as well as a few other changes are part of the Zmanim 1.1 beta release that will likely be released as a final release in a few days. Jan mentioned that:

“IMHO your API is easily the best and most accurate Open Source sunset/sunrise API out there”. He continued: “Officially (according to the Norwegian Meteorology Institute), the midnight sunset/sunrise is from May 20 to July 22 in Tromsoe, ie. the complete sun is above the horizon 24 hours. Parts of sun is visible 24 hours a day in Tromsoe from May 18th to July 25th. This is the same as in your calculations.” … “I have tested your calculations against other official midnight sunrise/sunset (part of sun) dates in Northern-Norway (North Cape, Hammerfest, Longyearbyen (78,049762N -15,458252E)) and they are spot on.”

In response to my question regarding his testing of the NOAACalculator versus the USNOCalculator he had an interesting and very practical answer

“We prefer to use USNO calculator as it is more in tune with the sunrise/sunset times printed in most newspapers. You see, our experience is that most users don’t look at the sun to determine sunrise/sunset but read the times in the newspaper. If our times don’t correspond to the printed ones, something is wrong with our system in their mind.”

Fix to NOAA Sunrise/Sunset Algorithm

pocket watchThe Zmanim API was developed from the ground up as an API which allows for easy plugging in of different algorithms. The Zmanim API ships with 3 “Calculator” implementations. Two calculators implement the US Naval Observatory’s algorithm, the SunTimesCalculator and the ZmanimCalculator. Both produce identical zmanim using slightly different code and are included for comparison. There is also the JSuntimeCalculator, an implementation of the NOAA algorithm by Jonathan Stott. I was recently contacted by Eliezer Bulka who wanted to know why sunrise/sunset times generated by the NOAA algorithm were about 2 minutes off of the sunrise/sunset times generated by the NOAA JavaScript implementation that is the source of the JSuntimeCalculator. To compare apples and apples required modification of the NOAA JavaScript to allow entry of decimal latitude/longitude, and changing the output to display seconds. No change was made to the algorithm itself. I then ported the JavaScript directly to Java. This involved nothing more than slight syntax changes between the languages. Once this was done I noticed that the sun rise/set output from the Java port exactly matched the output of the NOAA JavaScript. Analysis of Jonathan’s code showed (or at least my interpretation of it did) that there were two areas that caused the difference. Once is that he used a slightly different method of computing the Julian date, a key part of the algorithm. His change includes the time of day as part of the calculation. The net result of this change is that solar time generated using his algorithm varies based on the time of day the calculation is run, something that is incorrect. This means that there can be a discrepancy of up to one calendar day. If the user calculated sunrise at 11:59 PM, sunrise would be calculated for the following day even if the user attempted to calculate it for today. In addition, the other calculations do not match the output of the matching NOAA code. I have deprecated the JSuntimeCalculator and in its place added the NOAACalculator that was the result of the direct port of the NOAA code, shoehorned into the Zmanim API Calculator interface. I ran some tests to compare the maximum and minimum discrepancy between the 2 implementations, and calculations for Lakewood, NJ, latitude 40.0828, longitude -74.2094 show a discrepancy of between a minute and 34 seconds to a minute and 37 seconds for sunrise and sunset across an entire year of sunrise and sunset calculations. I also compared the USNO algorithm to the new NOAA implementation and ended up with a maximum deviation of less than 30 seconds, something that had been about 1.5 minutes apart previously. While I do believe that the Julian date calculation is a bug, I do not know that this is a case as far as the rest of the calculation, but it is clear that it does not match the NOAA implementation that is was based on, and I recommend that you download the latest version that has the new NOAACalculator that fixes this issue. In addition to this fix, an additional patch will be released later this week that will address issues with calculations in the arctic circle. Stay posted for the next post.

Calculation of Zmanim VS Other Sites

pocket watchA user contacted me with the following note (some details removed).

Could you please explain to me why there seems to be nearly a three minute discrepancy between the zemanim for XXXXX, NJ at 20 meters (exact location) and those listed for 20 meters on the site. Your site calculates 4/20 at 6:08:20 and theirs has it at 6:11:25….

I really can’t comment on the site since their code is not open source and I do not know the exact algorithm they use. The Zmanim Project code used here has 2 different algorithms available for calculating zmanim, one using the algorithm published by the USNO (US Navel Observatory), and the other from the NOAA (National Oceanic and Atmospheric Administration). I have 2 different implementations of the USNO algorithm, and both return the exact time to the millisecond, so I believe that the code is a correct implementation of the USNO algorithm. You can look through the code at my site and see if you find any issues. Having said that, I did a comparison between and my site using the USNO algorithm and both sites are within seconds (all calculations were for April 19 for XXXXX, NJ):

Site Algorithm Elevation
in Meters
Time ? 0 6:12:16 ? 20 6:11:25 USNO 0 6:12:18 USNO 20 6:11:31 NOAA 0 6:10:11 NOAA 20 6:09:24

Based on this chart, the sunrise difference between using USNO and who are probably also using the USNO algorithm is 3 seconds for sea level and 6 seconds at 20 meter elevation (see below for why the elevation calculation has this additional 3 second discrepancy). Keep in mind that while I was able to zoom in to the user’s exact location using the Google Map interface, is using a zip code level calculation, and they might be calculating using a slightly different location.
I believe that the times the user was referring to in his note were generated using the NOAA algorithm implementation. As mentioned above, At this point I have no information to indicate what algorithm is more accurate, and I will hopefully one day post more information on the accuracy of these algorithms.

As far as the elevation calculation, I use the formula

zenith = zenith + Math.toDegrees(Math.acos(earthRadiusInMeters / (earthRadiusInMeters + elevationMeters)));

found in Calendrical Calcuations, as mentioned on the Zmanim Calendar Generator page. For this time of year and the XXXXX location and a 20 meter elevation returns a time 47 seconds earlier than sea level using my calculation, and 51 seconds earlier using I reran the calculation using the more commonly used but less accurate formula of

adding 0.0347 * squareRoot(elevationMeters) to the zenith

that is mentioned in the Maaglay Tzedek written by Rabbi Moshe Kosower (as mentioned in the JavaDocs and Calendar Generator page) and the difference between the 0 and 20 meter elevation was the same 51 seconds that appeared in Besides relying on the more accurate calculation mentioned in Calendrical Calculations (considered the most authoritative book on calendars and astronomical time calculations), I spoke to Professor Moshe Koppel a few years ago about the subject and he validated the Calendrical Calculations algorithm (a seemingly common mathematical calculation). Looking back at the Maaglay Tzedek, it seems that this calculation includes changes to the refraction caused by the elevation, and I will have to research the subject some more. All this elevation difference boils down to an insignificant 3 second difference. Keep in mind that atmospheric refraction will have a much greater impact than this. Even if one were to know the exact atmospheric pressure, temperature and humidity, this varies in different parts of the atmosphere and would be extremely hard to calculate without measuring it at all elevations of the atmosphere. Please make sure to speak to a posek before using the time with elevation.

Elevation Lookup Added to Zmanim Calendar Generator

Java CalendarA lookup tool for elevation lookup was added to the Zmanim Calendar Generator page. This service is courtesy of Jonathan Stott’s elevation webservice. This Elevation data currently only covers all of mainland Europe (between latitudes 35°N and 60°N and longitudes 35°E and 15°W) and all of the contiguous states of the United States of America (between latitudes 20°N and 50°N and longitudes 65°W and 125°W). The source of the data is:

The terrain model used to find heights above sealevel is from the Shuttle Radar Topography Mission (SRTM) which was a joint project between the US National Geospatial-Intelligence Agency (NGA) and the National Aeronautics and Space Administration (NASA). Data was recorded for 11 days from the Space Shuttle Endevour from 11th February 2000. The data used here is at a resolution of 3 arc seconds (approximately 90m).

The lookup is done via an AJAX call.