Calculate the sunset and sunrise times for a particular location and date, as well as the different twilight phases (civil, nautical, astronomical) times. More details about the different sun position phases in timeanddate.com.
- Date: array('day', 'month', 'year')
- Latitude
- Longitude
- UTC DateTime object
use SolarPosition\Calculator;
$latitude = 40.433202;
$longitude = -3.690161;
$date = array('day'=>23, 'month'=>6, 'year'=>2017);
$sun = new Calculator();
$sunsetTime = $sun->getSunset($date, $latitude,$longitude);
/*
DateTime Object
(
[date] => 2017-06-23 19:48:35
[timezone_type] => 3
[timezone] => UTC
)
*/