The **sunrise equation** as follows can be used to derive the time of sunrise and sunset for any solar declination and latitude in terms of local solar time when sunrise and sunset actually occur:

cos
ω
∘
=
−
tan
ϕ
×
tan
δ
where:

ω
∘
is the hour angle at either sunrise (when

*negative* value is taken) or sunset (when

*positive* value is taken);

ϕ
is the latitude of the observer on the Earth;

δ
is the sun declination.

The Earth rotates at an angular velocity of 15°/hour. Therefore, the expression
ω
∘
×
h
o
u
r
15
∘
gives the interval of time before and after local solar noon that sunrise or sunset will occur.

The sign convention is typically that the observer latitude
ϕ
is 0 at the Equator, positive for the Northern Hemisphere and negative for the Southern Hemisphere, and the solar declination
δ
is 0 at the vernal and autumnal equinoxes when the sun is exactly above the Equator, positive during the Northern Hemisphere summer and negative during the Northern Hemisphere winter.

The expression above is always applicable for latitudes between the Arctic Circle and Antarctic Circle. North of the Arctic Circle or south of the Antarctic Circle, there is at least one day of the year with no sunrise or sunset. Formally, there is a sunrise or sunset when
−
90
∘
+
δ
<
ϕ
<
90
∘
−
δ
during the Northern Hemisphere summer, and when
−
90
∘
−
δ
<
ϕ
<
90
∘
+
δ
during the Northern Hemisphere winter. Out of these latitudes, it is either 24-hour daytime or 24-hour nighttime.

Also note that the above equation neglects the influence of atmospheric refraction (which lifts the solar disc by approximately 0.6° when it is on the horizon) and the non-zero angle subtended by the solar disc (about 0.5°). The times of the rising and the setting of the upper solar limb as given in astronomical almanacs correct for this by using the more general equation

cos
ω
∘
=
sin
a
−
sin
ϕ
×
sin
δ
cos
ϕ
×
cos
δ

with the altitude (a) of the center of the solar disc set to about −0.83° (or −50 arcminutes).

The generalized equation relies on a number of other variables which need to be calculated before it can itself be calculated. These equations have the solar-earth constants substituted with angular constants expressed in degrees.

n
=
J
d
a
t
e
−
2451545.0
+
0.0008
where:

n
is the number of days since Jan 1st, 2000 12:00.

J
d
a
t
e
is the Julian date;
2451545.0 is the equivalent Julian year of Julian days for 2000, 1, 1.5.
0.0008 is the fractional Julian Day for leap seconds and terrestrial time.
currently = 68.184 / 86400 without DUT1.

J
⋆
=
n
−
l
w
360
∘
where:

J
⋆
is an approximation of mean solar time at

l
w
expressed as a Julian day with the day fraction.

l
ω
is the longitude west (west is negative, east is positive) of the observer on the Earth;

M
=
(
357.5291
+
0.98560028
×
J
⋆
)
mod
360
where:

M is the solar mean anomaly used in a few of next equations.

C
=
1.9148
sin
(
M
)
+
0.0200
sin
(
2
M
)
+
0.0003
sin
(
3
M
)
where:

C is the Equation of the center value needed to calculate lambda (see next equation).

λ
=
(
M
+
C
+
180
+
102.9372
)
mod
360
where:

λ is the ecliptic longitude.
102.9372 is a value for the argument of perihelion.

(Amateur edit, so check before adopting). The value for the "Argument of Perihelion" is not constant, and changes (very slightly) per day. The JPL website gives the following for calculating the true value (valid to 3,000 AD): w0 = 102.9300589 degrees at J2000.0 and wt = 0.3179526 degrees per century (the amount by which this starting value changes). Therefore, one needs to calculate the number of centuries since J2000.0 for the date in question and multiply wt by that value to get the true Argument of Perihelion for the Earth. On 31-Jan-2017 at around 11.0 a.m. London, the elapse time since J2000.0 in centuries el = 6240.0007892/36525 = 0.17084191, so w = w0 + wt * el = 102.984378. The difference is very small, but may make an error in sun rise or set of about a minute as of the example date. Note JPL use 36525 as the number of days in a century, not 36524.22. It seems to work OK.

J
t
r
a
n
s
i
t
=
2451545.5
+
J
⋆
+
0.0053
sin
M
−
0.0069
sin
(
2
λ
)
where:

J

_{transit} is the Julian date for the local true solar transit (or solar noon).
2451545.5 is midnight or the beginning of the equivalent Julian year reference.

0.0053
sin
M
−
0.0069
sin
(
2
λ
)
is a simplified version of the equation of time. The coefficients are fractional day minutes.

sin
δ
=
sin
λ
×
sin
23.44
∘
where:

δ
is the declination of the sun.

*This is the equation from above with corrections for astronomical refraction and solar disc diameter.*

cos
ω
∘
=
sin
(
−
0.83
∘
)
−
sin
ϕ
×
sin
δ
cos
ϕ
×
cos
δ
where:

ω

_{o} is the hour angle from the observer's zenith;

ϕ
is the north latitude of the observer (north is positive, south is negative) on the Earth.

For observations on a sea horizon an elevation-of-observer correction, add
−
1.15
∘
elevation in feet
/
60
∘
, or
−
2.076
∘
elevation in metres
/
60
∘
to the -0.83° in the numerator's sine term. This corrects for both apparent dip and terrestrial refraction. For example, for an observer at 10,000 feet, add (-115°/60°) or about -1.92° to -0.83°.

J
s
e
t
=
J
t
r
a
n
s
i
t
+
ω
∘
360
∘
J
r
i
s
e
=
J
t
r
a
n
s
i
t
−
ω
∘
360
∘
where:

J

_{set} is the actual Julian date of sunset;
J

_{rise} is the actual Julian date of sunrise.