How sunrise and sunset are calculated

Sunrise is a definition before it is an observation, and a few lines of astronomy fix it to within a minute anywhere on Earth.

A sunrise time looks like an observation, something recorded by a person watching the horizon. It is not. It is computed from the date, the latitude and the longitude using equations that describe the Earth’s orbit and tilt, and the same equations produce the times for any place and any year. The sunrise and sunset tool here uses the set published by the US National Oceanic and Atmospheric Administration, NOAA, which are the ones behind most published tables; this guide explains what they calculate and what the result means.

The definition

Sunrise is the moment the upper edge of the sun appears on an ideal, flat, sea-level horizon. Two effects mean this happens before the sun’s centre is geometrically at the horizon. The sun is a disc about half a degree across, so its top edge shows when its centre is still 16 arc-minutes below. And the atmosphere bends light downward, lifting the apparent sun by a further 34 arc-minutes at the horizon. Together they give the standard figure: sunrise and sunset occur when the centre of the sun is 0.833° below the horizon, by geometry. The sun you see rising is already, in a straight-line sense, below the edge of the world.

What the equations do

The calculation has three parts. First, the sun’s declination, its angle north or south of the celestial equator, which swings between +23.44° at the June solstice and −23.44° at the December one; this comes from the date. Second, the equation of time, the difference between clock time and sun time, which varies through the year by up to about 16 minutes because the orbit is elliptical and the axis is tilted; this too comes from the date. Third, the hour angle at which the sun reaches the −0.833° altitude for the given latitude, from a single trigonometric formula. Solar noon is then 12:00 adjusted by the longitude and the equation of time, and sunrise and sunset are that noon minus and plus the hour angle. Nothing in it needs data: the site computes it in your browser from the coordinates alone.

Twilight

Three further altitudes define the twilights. Civil twilight, with the sun between the horizon and 6° below, is bright enough for outdoor activity without artificial light and is the legal boundary for several purposes, such as when vehicle lights are required. Nautical twilight, down to 12°, is when the horizon is still visible at sea for taking star sights. Astronomical twilight, to 18°, is when the sky is still too bright for the faintest objects; beyond it is full night. The golden hour tool uses the same machinery with the sun a few degrees above the horizon, which is where the light photographers want it.

Why the earliest sunset is not on the shortest day

In the northern mid-latitudes the earliest sunset comes around 8 to 12 December and the latest sunrise in early January, though the shortest day is the 21st. The cause is the equation of time: solar noon drifts later by about half a minute a day through December, so sunrise and sunset both move later, and the sunset reaches its earliest before the day is shortest while the sunrise reaches its latest afterwards. The same thing happens, reversed, in June. People who notice the evenings drawing out before Christmas are not imagining it.

Latitude, and the places where it fails

At the equator the sun rises and sets at close to 6:00 and 18:00 all year and the day length barely changes. The further from the equator, the larger the seasonal swing: London has 16 hours 38 minutes of daylight in June and 7 hours 50 minutes in December. Beyond the polar circles, at 66.56° and higher, there are dates when the sun does not rise or does not set, and the formula returns no solution. Tools have to handle that case explicitly and say “no sunrise” rather than produce a nonsense time, and the one here does. Near the circles, where the sun grazes the horizon, a difference of a few metres of altitude or a slightly different refraction can shift sunrise by many minutes, and the figures should be read as approximate.

How accurate the result is

The NOAA equations are accurate to within about a minute for latitudes up to about 72°, provided the horizon is flat. Real horizons are not. A sunrise over hills comes later than the tabulated time, a sunset over the sea from a cliff comes later too, because the observer is above the horizon, and refraction varies with temperature and pressure by enough to move the moment by a minute or two on an unusual day. Published tables, including these, describe an idealised horizon; what you see depends on where you stand. Day length, the difference between the two, is less sensitive, since the errors partly cancel.

What time zone the result is in

The calculation produces solar events in UTC, from the longitude; the time zone is applied afterwards for display. That is why the tool asks for a place rather than a zone, and why a city near the edge of its zone has its sunrise far from 6:00: in Vigo in western Spain, on Central European Time with the longitude of Ireland, the sun rises after 9:00 in December. The day and night map shows the terminator moving across the world, which is the same calculation drawn rather than tabulated. Moonrise and moonset use a different and harder set of equations, because the moon moves against the stars by its own diameter every hour; that tool has its own notes.

Sources

About the author

UnixClock is built, maintained and written by Niraj Kumar, a software developer who started it to replace the hand calculations and half-remembered offsets that kept going wrong across time zones. More about the site.

Frequently asked questions

Why does the sun appear before it has geometrically risen?

Because the atmosphere refracts light downward by about 34 arc-minutes at the horizon, and sunrise is defined by the upper edge of the disc, another 16 arc-minutes above the centre. Sunrise is computed when the centre is 0.833° below the horizon.

Why is the earliest sunset before the winter solstice?

Because solar noon drifts later through December, by the equation of time. Sunset reaches its earliest around 8 to 12 December in northern mid-latitudes while the shortest day is the 21st; the latest sunrise is in early January.

How accurate are calculated sunrise times?

Within about a minute for a flat horizon at latitudes below about 72°. Hills, elevation and unusual atmospheric conditions can move the observed moment by several minutes.

What is the difference between civil, nautical and astronomical twilight?

The sun’s depth below the horizon: 6°, 12° and 18° respectively. Civil twilight is bright enough to work outdoors; nautical twilight keeps the sea horizon visible; astronomical twilight ends when the sky is fully dark.

Related tools