1. Go to this page and download the library: Download sididev/prayer-times library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sididev / prayer-times example snippets
Sididev\PrayerTimes\PrayerTimes;
// Create an instance with the Muslim World League method
$prayerTimes = new PrayerTimes(PrayerTimes::METHOD_MWL);
// Get prayer times for today
$latitude = 33.5733; // Casablanca, Morocco
$longitude = -7.6454;
$timezone = 'Africa/Casablanca';
$times = $prayerTimes->getTimesForToday($latitude, $longitude, $timezone);
// Display the results
foreach ($times as $prayer => $time) {
echo "$prayer: $time\n";
}
use Sididev\PrayerTimes\PrayerTimes;
use DateTime;
use DateTimeZone;
$prayerTimes = new PrayerTimes();
$date = new DateTime('2025-01-01', new DateTimeZone('UTC'));
$times = $prayerTimes->getTimes($date, 33.5733, -7.6454, 'Africa/Casablanca');
use Sididev\PrayerTimes\PrayerTimes;
use Sididev\PrayerTimes\Method;
// Create a custom calculation method
$customMethod = new Method('Custom');
$customMethod->setFajrAngle(18)
->setIshaAngle(17)
->setMaghribAngle(0)
->setAsrFactor(1);
// Use the custom method
$prayerTimes = new PrayerTimes(PrayerTimes::METHOD_CUSTOM);
$prayerTimes->setCustomMethod($customMethod);
$times = $prayerTimes->getTimesForToday($latitude, $longitude, $timezone);
$prayerTimes = new PrayerTimes();
$prayerTimes->setElevation(350); // in meters
$times = $prayerTimes->getTimesForToday($latitude, $longitude, $timezone);
// Standard (midpoint between sunset and dawn)
$prayerTimes->setMidnightMode(PrayerTimes::MIDNIGHT_STANDARD);
// Jafari (midpoint between sunset and sunrise)
$prayerTimes->setMidnightMode(PrayerTimes::MIDNIGHT_JAFARI);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.