Muslims are supposed to perform five daily prayers, each at a specific prescribed time. These prayer times are determined based on the position of the sun and follow a precise schedule. This document provides an overview of these prayer times and explains the mathematical methods used to calculate them.
To determine the time span for each prayer (as well as for fasting), we need to establish eight key points of time throughout the day. These times are defined in the following table:
Time | Definition |
---|---|
Fajr | The moment when the sky first begins to lighten at dawn. |
Sunrise | The instant when the first edge of the Sun appears above the horizon. |
Dhuhr | The time when the Sun begins to decline after reaching its zenith (highest point in the sky). |
Asr | The moment when the length of an object's shadow equals a specific factor (commonly 1 or 2) of the object's height, plus its noon shadow length. |
Sunset | The instant when the Sun fully disappears below the horizon. |
Maghrib | Soon after sunset. |
Isha | The time when complete darkness sets in, and no scattered twilight remains in the sky. |
Midnight | The midpoint between sunset and sunrise (or, in some traditions, between sunset and Fajr). |
The next section provides details on how to mathematically compute these times for any given location, provided the geographical coordinates are known.
Two key astronomical measures are essential for accurately computing prayer times: the Equation of Time and the Declination of the Sun.
The Equation of Time represents the discrepancy between time measured by a sundial and a standard clock. The variation arises due to the Earth's axial tilt and the elliptical shape of its orbit, causing the Sun's apparent motion to fluctuate. As a result, the sundial can be ahead (fast) by up to 16 minutes 33 seconds (around November 3) or behind (slow) by up to 14 minutes 6 seconds (around February 12), as illustrated in the following graph:
The equation of time (Ref)
The Declination of the Sun is the angle between the Sun’s rays and the plane of the Earth’s equator. It varies continuously throughout the year due to the axial tilt of the Earth. This tilt—caused by the difference between the Earth’s rotational axis and its orbital plane—is responsible for seasonal changes and affects the calculation of prayer times.
The above two astronomical measures can be obtained accurately from The Star Almanac, or can be calculated approximately. The following algorithm from U.S. Naval Observatory computes the Sun's angular coordinates to an accuracy of about 1 arcminute within two centuries of 2000.
const d = jd - 2451545.0; // Julian date offset const g = 357.529 + 0.98560028* d; const q = 280.459 + 0.98564736* d; const L = q + 1.915 * sin(g) + 0.020 * sin(2*g); const R = 1.00014 - 0.01671* cos(g) - 0.00014* cos(2*g); const e = 23.439 - 0.00000036* d; const RA = arctan2(cos(e) * sin(L), cos(L)) / 15; const D = arcsin(sin(e) * sin(L)); // Declination of the Sun const EqT = q/15 - RA; // Equation of Time
To calculate prayer times for a given location, we need to know the latitude (L) and longitude (Lng) of the location, along with the local Time Zone for that location. We also obtain the equation of time (EqT) and the declination of the Sun (D) for a given date using the algorithm described in the previous section.
Dhuhr can be calculated easily using the following formula:
Dhuhr = 12 + TimeZone - Lng/15 - EqT.
The above formula indeed calculates the midday time, when the Sun reaches its highest point in the sky. A slight margin is usually considered for Dhuhr as explained in this note.
The time difference between the mid-day and the time at which sun reaches an angle α below the horizon can be computed using the following formula:
Astronomical sunrise and sunset occur at α=0. However, due to the refraction of light by terrestrial atmosphere, actual sunrise appears slightly before astronomical sunrise and actual sunset occurs after astronomical sunset. Actual sunrise and sunset can be computed using the following formulas:
Sunrise = Dhuhr - T(0.833),
Sunset = Dhuhr + T(0.833).
If the observer's location is higher than the surrounding terrain, we can consider this elevation into consideration by slightly increasing the above constant 0.833. However, in practice, the constant is considered the same regardless of the elevation.
There are differing opinions on what angle to be used for calculating Fajr and Isha. The following table shows several conventions currently in use in various countries (more information is available at this page).
Convention | Fajr Angle | Isha Angle |
---|---|---|
Muslim World League | 18 | 17 |
Islamic Society of North America (ISNA) | 15 | 15 |
Egyptian General Authority of Survey | 19.5 | 17.5 |
Umm al-Qura University, Makkah | 18.5 | 90 minutes after Maghrib, 120 minutes during Ramadan |
University of Islamic Sciences, Karachi | 18 | 18 |
Institute of Geophysics, University of Tehran | 17.7 | 141) |
Shia Ithna Ashari, Leva Research Institute, Qum | 16 | 14 |
For example, according to Muslim World League convention, Fajr = Dhuhr - T(18) and Isha = Dhuhr + T(17).
There are two main scholarly opinions regarding the calculation of Asr time:
The majority of Islamic schools of thought (Shafi'i, Maliki, Ja'fari, and Hanbali) state that Asr begins when the length of an object's shadow equals the object's own height plus its shadow length at noon. The Hanafi school follows a different interpretation, asserting that Asr begins when the shadow is twice the length of the object plus its shadow length at noon.
The following formula calculates the time difference between solar noon and the moment when an object's shadow reaches t times its own length, in addition to the object's shadow length at noon:
Thus, according to the first four schools of thought, Asr = Dhuhr + A(1), while in the Hanafi school, Asr = Dhuhr + A(2).
From the Sunni perspective, the time for Maghrib prayer begins once the Sun has completely set below the horizon, i.e., Maghrib = Sunset (with a precautionary delay of 1 to 3 minutes). In contrast, the dominant Shia opinion holds that Maghrib prayer should not be performed until the redness in the eastern sky, visible after sunset, has passed overhead. This is often accounted for by using a twilight angle like Maghrib = Dhuhr + T(4).
Midnight is generally calculated as the mean time from Sunset to Sunrise, i.e., Midnight = 1/2(Sunrise - Sunset). In Shia point of view, the juridical midnight (the ending time for performing Isha prayer) is the mean time from Sunset to Fajr, i.e., Midnight = 1/2(Fajr - Sunset).
In locations at higher latitude, twilight may persist throughout the night during some months of the year. In these abnormal periods, the determination of Fajr and Isha is not possible using the usual formulas mentioned in the previous section. To overcome this problem, several solutions have been proposed, three of which are described below.
In case Maghrib is not equal to Sunset, we can apply the above rules to Maghrib as well to make sure that Maghrib always falls between Sunset and Isha during the abnormal periods.
The formulas described above are implemented in JavaScript and can be obtained from this page.