1. Go to this page and download the library: Download tuxonice/suncalc-php 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/ */
tuxonice / suncalc-php example snippets
use Tlab\SunCalc\SunCalc;
$sunCalc = new SunCalc(new DateTimeImmutable('now', new DateTimeZone('Europe/Paris')), 48.85, 2.35);
// Format sunrise time from the DateTime object
$sunTimes = $sunCalc->getSunTimes();
$sunriseStr = $sunTimes['sunrise']->format('H:i');
// Get position of the sun (azimuth and altitude) at today's sunrise
$sunrisePos = $sunCalc->getPosition($sunTimes['sunrise']);
// Get sunrise azimuth in degrees
$sunriseAzimuth = $sunrisePos->azimuth * 180 / M_PI;