Muslim Prayer Times:

Calculate the time of Muslim prayer according to the geographic location. The five Islamic prayers are named Fajr, Zuhr, Asr, Maghrib and Isha. The timing of these five prayers varies from place to place and from day to day. It is obligatory for Muslims to perform these prayers at the correct time. The prayer times for any given location on earth may be determined mathematically if the latitude and longitude of the location are known. However, the theoretical determination of prayer times is a lengthy process. Much of this tedium may be alleviated by using computer programs.

Definition of prayer times:

Qibla Determination:

The problem of qibla determination has a simple formulation in spherical trigonometry. A is a given location, K is the Ka'ba, and N is the North Pole. The great circle arcs AN and KN are along the meridians through A and K, respectively, and both point to the north. The qibla is along the great circle arc AK. The spherical angle q = NAK is the angle at A from the north direction AN to the direction AK towards the Ka'ba, and so q is the qibla bearing to be computed. Let F and L be the latitude and longitude of A, and FK and LK be the latitude and longitude of K (the Ka'ba). If all angles and arc lengths are measured in degrees, then it is seen that the arcs AN and KN are of measure 90 - F and 90 - FK, respectively. Also, the angle ANK between the meridians of K and A equals the difference between the longitudes of A and K, that is, LK - L, no matter what the prime meridian is. Here we are given two sides and the included angle of a spherical triangle, and it is required to determine one other angle. One of the simplest solutions is given by the formula:

                  -1              sin(LK - L)
           q = tan   ------------------------------------------
                         cos F tan FK - sin F cos(LK - L) 

In this Equation, the sign of the input quantities are assumed as follows: latitudes are positive if north, negative if south; longitudes are positive if east, negative if west. The quadrant of q is assumed to be so selected that sin q and cos q have the same sign as the numerator and denominator of this Equation. With these conventions, q will be positive for bearings east of north, negative for bearings west of north.

Reference: The Correct Qibla, S. Kamal Abdali k.abdali@acm.org
PDF version in http://www.patriot.net/users/abdali/ftp/qibla.pdf

Example Output 1:

Damascus, Syria Wednesday May 8, 2024

Imsak: 3:47
Fajr: 3:57
Sunrise: 5:35
Dhuhr: 12:31
Asr: 16:14
Sunset: 19:27
Maghrib: 19:29
Isha: 20:54
Midnight: 0:31

Imsak: Wednesday 8 May 2024 3:47 am
Fajr: Wednesday 8 May 2024 3:57 am
Sunrise: Wednesday 8 May 2024 5:35 am
Dhuhr: Wednesday 8 May 2024 12:31 pm
Asr: Wednesday 8 May 2024 4:14 pm
Sunset: Wednesday 8 May 2024 7:27 pm
Maghrib: Wednesday 8 May 2024 7:29 pm
Isha: Wednesday 8 May 2024 8:54 pm
Midnight: Thursday 9 May 2024 12:31 am

Qibla Direction (from the north direction): 164.70473621919 (click here)


Example Code 1:

<?php
    date_default_timezone_set
('UTC');
    
    
$Arabic = new \ArPHP\I18N\Arabic();

    
// Latitude, Longitude, Zone, and Elevation
    
$Arabic->setSalatLocation(33.5236.313691);
    
    
// Month, Day, and Year
    
$Arabic->setSalatDate(date('n'), date('j'), date('Y'));

    echo 
"<b>Damascus, Syria</b> ".date('l F j, Y')."<br /><br />";

    
// Salat calculation configuration: Egyptian General Authority of Survey
    
$Arabic->setSalatConf('Shafi', -0.833333,  -17.5, -19.5'Sunni');
    
$times $Arabic->getPrayTime();
    
    echo 
"<b>Imsak:</b> {$times[8]}<br />";
    echo 
"<b>Fajr:</b> {$times[0]}<br />";
    echo 
"<b>Sunrise:</b> {$times[1]}<br />";
    echo 
"<b>Dhuhr:</b> {$times[2]}<br />";
    echo 
"<b>Asr:</b> {$times[3]}<br />";
    echo 
"<b>Sunset:</b> {$times[6]}<br />";
    echo 
"<b>Maghrib:</b> {$times[4]}<br />";
    echo 
"<b>Isha:</b> {$times[5]}<br />";
    echo 
"<b>Midnight:</b> {$times[7]}<br /><br />";

    echo 
'<b>Imsak:</b> '   .date('l j F Y g:i a'$times[9][8]).'<br />';
    echo 
'<b>Fajr:</b> '    .date('l j F Y g:i a'$times[9][0]).'<br />';
    echo 
'<b>Sunrise:</b> ' .date('l j F Y g:i a'$times[9][1]).'<br />';
    echo 
'<b>Dhuhr:</b> '   .date('l j F Y g:i a'$times[9][2]).'<br />';
    echo 
'<b>Asr:</b> '     .date('l j F Y g:i a'$times[9][3]).'<br />';
    echo 
'<b>Sunset:</b> '  .date('l j F Y g:i a'$times[9][6]).'<br />';
    echo 
'<b>Maghrib:</b> ' .date('l j F Y g:i a'$times[9][4]).'<br />';
    echo 
'<b>Isha:</b> '    .date('l j F Y g:i a'$times[9][5]).'<br />';
    echo 
'<b>Midnight:</b> '.date('l j F Y g:i a'$times[9][7]).'<br /><br />';
    
    
$direction $Arabic->getQibla();
    echo 
"<b>Qibla Direction (from the north direction):</b> $direction<br />";
    echo 
"(<a href=\"./qibla.php?d=$direction\" target=_blank>click here</a>)<br /><br/>";

Related Documentation: setSalatLocation, setSalatDate, setSalatConf, getPrayTime, getQibla