PHP has a function for calculating sunset and sunrise—for Earth


<?php
$sun 
date_sun_info(time(), 51.50, -0.127);
var_dump$sun );
?>
Output
array(9) { ["sunrise"]=> int(1780199250) ["sunset"]=> int(1780258136) ["transit"]=> int(1780228693) ["civil_twilight_begin"]=> int(1780196662) ["civil_twilight_end"]=> int(1780260724) ["nautical_twilight_begin"]=> int(1780192668) ["nautical_twilight_end"]=> int(1780264718) ["astronomical_twilight_begin"]=> bool(true) ["astronomical_twilight_end"]=> bool(true) }