date_default_timezone_set ( "America/Sao_Paulo" );
$dtz = new DateTimeZone('America/Sao_Paulo');
$dt = new DateTime('now', $dtz);
$offset = $dtz->getOffset( $dt ) / 3600;
$por_do_sol = date_sunset(time(), SUNFUNCS_RET_STRING, -20.7965404, -49.3826269, $zenith = ini_get("date.sunset_zenith"), $offset);
I adapted a script I found on the internet ... basically the variable $ por_do_sol is a string with the sunset time in my city, which I want to know how do I compare with the current time and know if already passed the sunset.