Sunrise and sunset times

This applet computes sunrise, sunset and twilight times
The sunrise and sunset times at any given day and location can be found using so-called Sunrise equation[1]


is the sun declination.
is the latitude of the observer
is the time, expressed in degrees (with 24 hours corresponding to 360 degrees). Take negative value for sunset and positive value for sunrise.

Computing declination

An object has a declination 0° on the (celestial) equator, +90° at the north pole and −90° at the south pole. The Sun's declination is approximately equal to[2]

where -23.45 is the axial tilt of the earth. N is the number of the days elapsed after the 1 of January that year.

There are also various more complex, but also more precise formulas. For instance, the same source gives the formula


is the day angle (fractional year) in radians.

Changes of the declination over year give the raise of seasons.

Given formulas compute the sunrise and sunset times in the vacuum (if it would be in the Moon). For more precise output, refraction in the Earth's atmosphere must also be taken into consideration:

where a is the altitude of the centre of the solar disc in angular units (about 0.83°)


  1. 1 Wikipedia on Sunrise Equation
  2. 2 Desmond Fletcher (2007) Solar Declination