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:

Damascus, Syria Monday December 23, 2024

Imsak: 5:49
Fajr: 5:59
Sunrise: 7:31
Dhuhr: 12:34
Asr: 15:14
Sunset: 17:37
Maghrib: 17:39
Isha: 18:58
Midnight: 0:34

Imsak: Monday 23 December 2024 5:49 am
Fajr: Monday 23 December 2024 5:59 am
Sunrise: Monday 23 December 2024 7:31 am
Dhuhr: Monday 23 December 2024 12:34 pm
Asr: Monday 23 December 2024 3:14 pm
Sunset: Monday 23 December 2024 5:37 pm
Maghrib: Monday 23 December 2024 5:39 pm
Isha: Monday 23 December 2024 6:58 pm
Midnight: Tuesday 24 December 2024 12:34 am

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


Example Code:

<?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/>";