Work out sunrise sunset on a date instantly with clear inputs, formula shown and shareable results.
Sunrise and sunset are symmetrical about solar noon, separated by twice the sunrise hour angle whose cosine is -tan(latitude)tan(declination). At 51.5 degrees north on the June solstice the half-day is 8.18 hours, so the Sun rises at 03:49 and sets at 20:11 in local solar time - which clock time then shifts by longitude and the equation of time.
Sunrise hour angle
cos(H) = -tan(latitude) x tan(declination)
Sunrise and sunset
solar noon minus and plus H/15 hours
Published times use clock time rather than solar time, and allow for atmospheric refraction and the Sun's disc, which adds about three minutes at each end.
The cosine goes out of range, meaning the Sun never rises or never sets. Latitude is limited to 66 degrees here for that reason.