Logo for ammarahmed.ca
BackReligion
Islamic Prayer Times and their Calculation cover image
May 09, 2023

Islamic Prayer Times and their Calculation

#Islam

Islam consists of 5 basic pillars which make up the duties that a Muslim must perform. These are:

  1. Testifying the Oneness of Allah (God) and Muhammad Peace Be Upon Him (PBUH) as the slave and final messenger of Allah.
    1. The 5 daily prayers
      1. Fasting during the month of Ramadan
        1. Paying the alms tax (Zakat)
          1. The once-in-a-lifetime pilgrimage to Makkah (Hajj)

            Out of these, the first one is obviously the most important as it is what makes a Muslim into a Muslim. The second most important out of these is the five daily prayers. So much so that some Scholars of Islam go as far as saying that any Muslim who does not establish their 5 daily prayers has left the fold of Islam.

            The importance of the 5 daily prayers is further proven through the absolute necessity of them in Islamic law. As in, fasting can be missed for a variety of reasons such as traveling, sickness, and some other extenuating circumstances. Zakat can be missed if a person does not have the minimum amount of wealth to be eligible for it. Hajj can be missed if a person does not have enough money to make the pilgrimage or if they are sick, old, etc. However, the 5 daily prayers are never allowed to be missed completely. If they are missed, they must be made up later. Even if a person is bedridden, they must complete their prayers by making the movements with their head. The only exemption from prayer is given to women when they are menstruating.

            Allah states in the Quran regarding the prayer:

            “But if they repent, perform prayer, and pay alms-tax, then they are your brothers in faith. This is how We make the revelations clear for people of knowledge.” - Quran (9:11)

            In another place, He states:

            “But they were succeeded by generations who neglected prayer and followed their lusts and so will soon face the evil consequences. As for those who repent, believe, and do good, it is they who will be admitted into Paradise, never being denied any reward.” - Quran (19, 59-60)

            The Quran clearly establishes that establishing prayer is an essential part of being a Muslim and that it is one of the most important obligations that must be fulfilled.

            Furthermore, the Prophet Muhammad (PBUH) is also clear in the heavy importance of the daily prayers:

            Abdullah bin Buraidah narrated that his father said: “The Messenger of Allah (ﷺ) said: ‘The covenant that distinguishes between us and them is prayer; so whoever leaves it, he has committed Kufr [disbelieved].’” - Sunan Ibn Majah (1079) (Book 5, Hadith 277)

            Prayer Times

            It is clear that performing the prayers is extremely important for a Muslim, however, it is also necessary to perform them at the correct times. We have 5 daily prayers which are named:

            1. Fajr (early morning)
              1. Zuhr (midday)
                1. Asr (middle of the day)
                  1. Maghrib (sunset)
                    1. Isha (night)

                      Each prayer has a start time and end time. Praying the prayer in between the start and end time will count as praying the prayer on time, however, it is always better to pray closer to the start time rather than near the end time.

                      As Islam was revealed to the Prophet Muhammad (PBUH) in a time before clocks, the prayer times were based on the position of the sun. The people would know about the start of prayer time when the Adhan (call to prayer) was called in the city.

                      Fajr

                      The start time for Fajr begins at dawn and ends when the sun rises. In Islam, the correct term for when Fajr starts is called Subh-Sadiq. This is also the time when Muslims should stop eating when fasting in the month of Ramadan or otherwise. Hence, we can deduce a more accurate time for Fajr from the Quran where Allah speaks about when to stop eating for fasting. Allah states:

                      … [You may] eat and drink until you see the light of dawn breaking the darkness of night, then complete the fast until nightfall. Do not be intimate with your spouses while you are meditating in the mosques. These are the limits set by Allah, so do not exceed them. This is how Allah makes His revelations clear to people, so they may become mindful [of Him]. - Quran (2:187)

                      Therefore, the time for Fajr starts when there is a string of white light on the horizon in the morning. The end time for Fajr is referenced in Hadith (sayings) of the Prophet PBUH:

                      'Abdullah b. 'Amr b. al-'As reported: The Messenger of Allah (ﷺ) was asked about the times of prayers. He said: The time for the morning prayer (lasts) as long as the first visible part of the rising sun does not appear and the time of the noon prayer is when the sun declines from the zenith and there is not a time for the afternoon prayer and the time for the afternoon prayer is so long as the sun does not become pale and its first visible part does not set, and the time for the evening prayer is that when the sun disappears and (it lasts) till the twilight is no more and the time for the night prayer is up to the midnight. - Sahih Muslim (612e) (Book 5, Hadith 223)

                      Zuhr

                      The timing for the mid-day prayer is also referenced in the above hadith (Muslim, 612). It starts slightly after the sun reaches its zenith (the middle of the sky) and it ends when the middle of the day prayer (Asr) time starts. The above hadith (Muslim, 612) mentions that there is no start time for the Asr prayer, however, there are other ahadith (p. hadith) which mention it’s start time.

                      Asr

                      There are two different start times for the Asr prayer based on the following hadith:

                      Narrated by Abdullah Ibn Abbas: The Messenger of Allah (ﷺ) said: Gabriel (ﷺ) led me in prayer at the House (i.e. the Ka'bah). He prayed the noon prayer with me when the sun had passed the meridian to the extent of the thong of a sandal; he prayed the afternoon prayer with me when the shadow of everything was as long as itself; he prayed the sunset prayer with me when one who is fasting breaks the fast; he prayed the night prayer with me when the twilight had ended; and he prayed the dawn prayer with me when food and drink become forbidden to one who is keeping the fast. On the following day, he prayed the noon prayer with me when his shadow was as long as himself; he prayed the afternoon prayer with me when his shadow was twice as long as himself; he prayed the sunset prayer at the time when one who is fasting breaks the fast; he prayed the night prayer with me when about the third of the night had passed; and he prayed the dawn prayer with me when there was a fair amount of light. Then turning to me he said: Muhammad, this is the time observed by the prophets before you, and the time is anywhere between two times. - Sunan Abi Dawud (393) (Book 2, Hadith 393)

                      As mentioned above, there are two acceptable start times for the Asr prayer:

                      1. When an object’s shadow is the same length as the object
                        1. When an object’s shadow is twice the length of the object

                          From this, the schools of thought of Islamic Jurisprudence have differed on which start time to use. The majority (Shafi, Maliki, Hanbali) of the 4 main schools of thought have taken the earlier time (same length). Whereas, the Hanafi school has taken the later time (twice length). The end time for Asr is when Maghrib time starts.

                          Maghrib

                          The maghrib prayer’s start time is sunset as mentioned in Quran (2:187), Muslim 612, and Abi Dawud (393). The end time for Maghrib is when the time for Isha starts.

                          Isha

                          The time for Isha starts when “twilight has ended” (Abi Dawud, 393). This means that Isha time starts once there is no longer any redness left in the sky after sunset or, in other words, once the night has completely started. The end time for Isha is at midnight as mentioned in Muslim 612.

                          Calculation

                          As mentioned above, all the prayer times are defined by the sun’s position, however, in today’s time, all the timings are defined at set times for each day. So, the question is; how are these times calculated? The basis of this calculation is dependent on the sun’s position in the sky using angles. However, the sun’s position in the sky and how fast it is moving through the sky are dependent on location and the day of the year. Therefore, in order to calculate these times, we require 3 parameters (with various other optional parameters):

                          1. Location (latitude, longitude)
                            1. Timezone offset
                              1. Date

                                Using these parameters, the calculation of prayer times requires 2 mathematically calculated values:

                                1. Equation of time
                                  1. Declination of the sun

                                    Equation of Time

                                    The equation of time, in simple terms, is the difference between the actual time and the sun’s actual position. The actual time is set as 24 hours in a day using the sun’s movement around the equator at a uniform rate. In reality, the sun does not move around the equator at a uniform rate due to the eccentricity of the Earth’s orbit around the Sun. Therefore, in order to calculate prayer times using the actual sun’s position, we require the Equation of Time (EqT). In other words, EqT is the difference between the time that would be seen by a sundial and a regular clock. The formula for the EqT is as follows:

                                    where

                                    Both and are values of Greenwich Hour Angles. Greenwich Hour Angle is the angle from the zenith (horizon) to the sun’s position. Therefore, the is also a Greenwich Hour Angle. In the formula, is the Greenwich Hour Angle of the actual sun (sundial) and is the Greenwich Hour Angle of the actual time (clock).

                                    Declination of the sun

                                    The declination of the sun is the angle between the rays of the sun and the plane of the earth’s equator. This is required for the calculation of prayer times as all prayer times are defined through the sun’s position as viewed from an observer on Earth.

                                    Approximation

                                    The calculation of the exact equation of time is very difficult to accomplish, therefore, we can implement an algorithm developed by the US Naval Observatory to approximate the values for both the and the declination of the sun which is accurate to 1 minute for 2 centuries (2000 years)

                                    The approximation implements the Julian Date () to approximate these values. The is the number of days elapsed from 12 PM (noon), January 1st, 4713 BC. This may seem arbitrary, however, a simple reason as to why it’s used in modern astronomical calculations is because there are probably very few use cases where a date prior to this would be required, reducing the prevalence of negative numbers. For further reading on the Julian Date, you can reference the Wikipedia article here.

                                    Julian Date Calculation

                                    In order to calculate the Julian Date (), we can use the following algorithm, given the Gregorian date ( = Gregorian year, = Gregorian month (1-12), = Day of the month (1-31)).

                                    If :

                                    We do this because January and February are thought to be the 13th and 14th months of the previous year in this algorithm.

                                    NOTE:

                                    Once we have calculated the , we can move on with the algorithm for and the declination of the sun.

                                    All calculations are done in degrees and all angles are normalized from 0-360 using the following function

                                    All hours are also normalized to be between 0 - 24 using the following function

                                    From this, we need to implement another calculation that will provide the time it takes for the sun to get from noon to a certain angle, . This is necessary because it is the basis for how our prayer times will be calculated. For example, the time for sunset would be calculated by adding the time it takes for the sun to get to angle from when the sun is at its zenith (noon).

                                    Mid-day Calculation

                                    To start, we need to calculate the time for mid-day () as it will be the basis for the remaining calculations. The mid-day calculation will require the timezone offset () (e.g. Eastern Standard Time, ) and the longitude value ():

                                    NOTE: Moving forwards, all time calculations will be given in fractional hours (e.g. 1:30 PM = 13.5)

                                    Sun Angle Calculation

                                    As mentioned above, we need a method to calculate the time it takes for the sun to reach an angle, from midday. We can use the following formula to calculate this.

                                    where is the latitude value and is the declination of the sun.

                                    Prayer Time Calculations

                                    Given the formulas above, we can calculate most prayer times.

                                    Dhuhr

                                    The time for Dhuhr is simply mid-day, so, Dhuhr would occur at .

                                    Fajr and Isha

                                    The calculation for Fajr and Isha is the point of contention for most Islamic authorities as it entails defining an angle for when Fajr and Isha should occur. As mentioned above, the time for Fajr starts when there is a string of white light across the horizon. This is a difficult metric to put a quantitative value to as it may be different for different parts of the world. Therefore, various Islamic authorities have defined various angles for both Fajr and Isha calculations. You can find all these angle values here, however, for ease of explanation, I will take the ISNA (Islamic Society of North America) angles to show sample calculations.

                                    ISNA defines Fajr and Isha to both occur at a 15-degree angle. This means that Fajr will occur at

                                    and Isha will occur at

                                    Sunrise and Maghrib

                                    Sunrise is also an important time for Muslims as it entails when the time for offering Fajr prayer has ended.

                                    The calculation of sunrise and sunset (maghrib) are trivial as they occur when . The reason why it is not exactly 0 is because that would be defined as the astronomical sunset and sunrise. Due to light diffraction, the actual sunrise and sunset occur a little before/after this. For this reason, is used instead.

                                    Thus, sunrise would be

                                    and sunset (maghrib) would be

                                    NOTE: Shia take maghrib to be well after sunset, when the redness from the sky has faded, therefore, for Shia maghrib, .

                                    Asr

                                    In order to calculate Asr, we need to implement another formula as the definition of Asr is when the shadow of an object is the same length as itself (Shafi, Maliki, Hanbali) or when the shadow of an object is twice its length (Hanafi). In order to calculate this, we can use the following formula

                                    where (length of shadow), is the latitude and is the declination of the sun.

                                    From this, the Hanafi Asr time would be

                                    and the non-Hanafi Asr time would be

                                    Given these calculated values in fractional hours, it is trivial to convert them into a readable time format.

                                    Edge Cases

                                    This was a simple introduction to the calculation of prayer times. There are many nuanced aspects and factors that can be taken into consideration such as accounting for extremely high latitudes. Places with very high latitudes can have light outside all day and night during some months so there are methods devised to calculate prayer times for them which I have not discussed.

                                    It’s quite interesting to me how much mathematics goes into the calculation of something so seemingly simple.