Prayer time science
How Prayer Times Are Calculated From the Sun's Position
Prayer times follow the sun: solar noon for Dhuhr, shadow length for Asr, sunset for Maghrib, twilight for Fajr and Isha. The formulas, with a worked example.
By Tahir Nasuru · · 9 min read

Prayer times are calculated from the sun's position in the sky at your latitude and longitude on a given date. Dhuhr starts just after the sun crosses the meridian (solar noon). Asr starts when shadows reach a set length. Maghrib starts at sunset, and Fajr and Isha are tied to the sun being a set angle below the horizon. Every one of these moments comes from the same few astronomical quantities: the sun's declination, the equation of time, and the hour angle.
Key Takeaways
- Two numbers describe the sun on any date: its declination (how far north or south of the equator it is) and the equation of time (how far sundial time runs ahead of or behind clock time).
- Solar noon gives Dhuhr. Every other prayer is an hour angle before or after solar noon, at 4 minutes of time per degree.
- Asr is defined by shadow length, which the formula turns into a target sun altitude. A shadow factor of 1 or 2 gives the earlier or later Asr setting.
- A hand calculation for London on 9 November 2026 lands within two minutes of the open-source adhan library.
What the hadith define, and what astronomy measures
The prayer times are defined in the hadith by things anyone can observe: the sun passing its highest point, the length of shadows, sunset, and the glow of twilight. In Sahih Muslim 612d, the Prophet ﷺ says the time of Dhuhr is "when the sun passes the meridian," and lists Asr until the sun becomes pale, Maghrib until the twilight ends, Isha up to the middle of the night, and Fajr from the appearance of dawn until sunrise.
Jami' at-Tirmidhi 149, graded Hasan (Darussalam) on sunnah.com, describes Jibril leading the Prophet ﷺ in prayer on two days. On the first day Asr was prayed when "everything was similar (to the length of) its shadow," and on the second when the shadow was "about twice as long." Maghrib was prayed "when the sun had set."
Astronomy cannot decide which of these markers a community follows. What it can do is predict, for any place and date, the clock time at which each marker happens. Which definitions and angles to use is a question for scholars and your local mosque; the arithmetic below only shows how the times come out once those choices are made.
The two numbers that describe the sun each day
Solar declination
Declination is the sun's angle north or south of the celestial equator. It swings between about +23.4° in June and −23.4° in December because the Earth's axis is tilted by about 23.4°. Declination sets how high the sun climbs at noon and how long it stays above the horizon.
The US Naval Observatory's approximate solar coordinates give a short algorithm for it. You count days from 1 January 2000, compute the sun's mean anomaly and ecliptic longitude, and then use sin(declination) = sin(obliquity) × sin(longitude). The USNO says this is accurate to about 1 arcminute within two centuries of 2000, which it describes as adequate for sunrise, sunset and solar transit.
The equation of time
The equation of time is the gap between sundial time and clock time. The sun does not cross the meridian at exactly 12:00 local mean time every day. A Physics Today explainer by Anna Sajina traces it to two causes, the eccentricity of the Earth's orbit and the tilt of its axis. The sundial lags a clock by up to 14 minutes in February and runs ahead by up to 16 minutes in November.
That is why Dhuhr in your city drifts by half an hour across the year even though your longitude never changes.
Solar noon gives Dhuhr
Solar noon is the moment the sun crosses your north-south meridian. The USNO rise, set and twilight definitions call this transit "local solar (sundial) noon." It is also when shadows are shortest.
The NOAA Global Monitoring Division's General Solar Position Calculations gives the formula in minutes after midnight UTC:
solar noon = 720 − 4 × longitude − equation of time
Longitude is in degrees, positive east. The factor 4 comes from the Earth turning 360° in 1,440 minutes, so each degree of longitude is 4 minutes. Add your time zone offset to get local clock time.
Dhuhr begins once the sun has passed the meridian, so calculators start it at or just after solar noon. Some methods add a few minutes as a margin.
The hour angle turns any sun altitude into a clock time
The hour angle is how far the sun has moved around the sky since (or before) solar noon, in degrees. One degree equals 4 minutes, so an hour angle of 15° is one hour after noon.
To find when the sun reaches a target altitude h at latitude φ with declination δ, solve:
cos(hour angle) = (sin h − sin φ × sin δ) / (cos φ × cos δ)
Then the event is at solar noon minus 4 × hour angle in the morning, or plus 4 × hour angle in the afternoon. This one formula gives sunrise, Asr, Maghrib, Fajr and Isha. Only the target altitude changes.
| Prayer | Target sun altitude h | Before or after solar noon |
|---|---|---|
| Fajr | Twilight angle below the horizon (for example −18°) | Before |
| Sunrise (end of Fajr) | −0.833° | Before |
| Dhuhr | Meridian crossing (hour angle 0) | At noon |
| Asr | From the shadow rule (next section) | After |
| Maghrib | −0.833° | After |
| Isha | Twilight angle below the horizon (for example −17° or −18°) | After |
Why sunset is −0.833°, not 0°
Sunrise and sunset are defined by the top edge of the sun touching the horizon, and the atmosphere bends light so the sun looks higher than it is. The USNO page adds the sun's average apparent radius (16 arcminutes) to the average refraction at the horizon (34 arcminutes). That puts the sun's centre 50 arcminutes, or 0.833°, below the horizon at the moment of sunset. NOAA's sunrise formula uses the same value as a zenith of 90.833°.
Maghrib, at sunset, uses this altitude.
Fajr and Isha use twilight angles
Fajr and Isha are tied to the sun being a fixed angle below the horizon. The USNO defines astronomical twilight as the sun's centre 18° below the horizon. Calculation methods choose their own Fajr and Isha angles. The adhan library's list of methods runs from 14° to 20°, and its Umm al-Qura method sets Isha a fixed 90 minutes after Maghrib instead of using an angle.
Those choices are the main reason two apps disagree. The post on Fajr and Isha twilight angles explains what each angle means in the sky, and the comparison of prayer time calculation methods lists which organisations use which values.
At high latitudes the sun may never get that far below the horizon. In London (51.5° N) near the June solstice, the sun bottoms out about 15° below the horizon at midnight. The right-hand side of the hour-angle formula then falls below −1, outside the range a cosine can take, so there is no solution and software switches to a high-latitude rule.
How the Asr shadow rule becomes a formula
Asr is the one prayer defined by shadow length rather than by a sun angle, so the formula has one extra step. A vertical stick of height 1 casts a shadow of length cot(h) when the sun is at altitude h.
At noon the sun is at its highest, and the stick already casts a shadow. The noon altitude is 90° − |φ − δ|, so the noon shadow is tan|φ − δ|. Asr begins when the shadow equals the noon shadow plus a set multiple k of the stick's height:
cot(Asr altitude) = k + tan|φ − δ|
With k = 1 you get the earlier Asr, matching the first day in Tirmidhi 149, when "everything was similar (to the length of) its shadow." With k = 2 you get the later Asr, matching the second day, when the shadow was "about twice as long as it." The open-source adhan library's Madhab setting returns a shadow length of 1 for its "Shafi" option and 2 for its "Hanafi" option. Solve for the altitude, then use the hour angle formula as before.
Accounting for the noon shadow matters most in winter and at high latitudes, where the noon shadow is long. On our sister site Everyday Muslim, a guide to Asr settings explains how to pick the setting your community follows.
A worked example: London on 9 November 2026
Here is the full calculation for central London (51.51° N, 0.13° W) on Monday 9 November 2026 (29 Jumada al-Awwal 1448). London is on GMT (UTC+0) that day. The sun's position was computed at solar noon with the USNO approximate algorithm, then checked against the adhan library (version 4.4.3) using the Muslim World League method (Fajr 18°, Isha 17°).
- Sun's position at noon. Declination −16.93°. Equation of time +16.19 minutes, so the sundial is ahead of the clock.
- Solar noon. 720 − 4 × (−0.13) − 16.19 = 704.32 minutes after midnight, which is 11:44:19 GMT.
- Noon shadow. |51.51 − (−16.93)| = 68.44°. The sun is 21.56° high and a 1 m stick casts a 2.53 m shadow.
- Asr altitude. For k = 1: cot(h) = 1 + 2.53 = 3.53, so h = 15.81°. For k = 2: cot(h) = 4.53, so h = 12.45°.
- Hour angles. Asr (k = 1) 32.81°, Asr (k = 2) 41.86°, sunrise and sunset 69.00°, Fajr (−18°) 97.82°, Isha (−17°) 96.21°.
- Clock times. Multiply each hour angle by 4 minutes and add it to, or subtract it from, 11:44:19, then round to the nearest minute.
| Prayer | Hand calculation (GMT) | adhan library, MWL (GMT) |
|---|---|---|
| Fajr | 05:13 | 05:13 |
| Sunrise | 07:08 | 07:08 |
| Dhuhr | 11:44 (solar noon) | 11:45 |
| Asr (shadow factor 1) | 13:56 | 13:54 |
| Asr (shadow factor 2) | 14:32 | 14:31 |
| Maghrib | 16:20 | 16:20 |
| Isha | 18:09 | 18:09 |
The library's Dhuhr is a minute later because its Muslim World League definition adds one minute to Dhuhr. The Asr differences of one to two minutes come from which declination is used for the noon shadow: the hand calculation uses the value at solar noon, while the library uses the value at the start of the day. The library also interpolates the sun's position across the day for its other times, which is why careful software and a quick hand calculation agree to within a minute or two rather than to the second.
Calculations like this assume an observer at sea level with a flat horizon, so local terrain and elevation can make the sunrise and sunset you actually see differ slightly.
Common questions
Why do prayer times change every day?
Declination and the equation of time both change daily. Declination changes how long the day is, which moves Fajr, sunrise, Asr, Maghrib and Isha. The equation of time moves solar noon, and every other prayer moves with it.
How far apart are the two Asr settings?
It depends on the season and the place, because the gap is the time the shadow takes to grow by one extra stick-length. Computed with the adhan library for central London in 2026, the later setting falls 75 minutes after the earlier one on 21 June, 37 minutes on 9 November and 29 minutes on 21 December.
Is a calculated time the same as an observed one?
No. A calculation predicts when the sun reaches an angle under average atmospheric conditions. Twilight angles in particular are conventions chosen to approximate what observers see. Local mosques may also publish timetables that add margins or follow a specific method.
Check the times for your own location
Use the daily prayer times page to see Fajr, Dhuhr, Asr, Maghrib and Isha for your location, and switch the calculation method or Asr setting to see how each choice moves the times. The monthly timetable shows how solar noon and the other times drift across a month as declination and the equation of time change. If your mosque's timetable differs, ask which method and Asr setting it uses before changing yours. For why the Islamic day starts at Maghrib rather than midnight, see why the Islamic day begins at sunset.


