Thanks to all for the answers. In my context I have all I need through a function called date_sun_info which returns something like this, given latitude and longitude and a date:
[sunrise] => 319016278
[sunset] => 319040766
[transit] => 319028522
[civil_twilight_begin] => 319012129
[civil_twilight_end] => 319044915
[nautical_twilight_begin] => 319007891
[nautical_twilight_end] => 319049153
[astronomical_twilight_begin] => 319003840
[astronomical_twilight_end] => 319053204
I've put this only as a reference for further searches and I'll still select an answer based on the other people contributions.
Thanks