How sunrise and sunset times are calculated โ€” latitude, the seasons, and the equation of time

Sunrise tomorrow can be computed for any point on Earth to within a minute with nothing but the date, latitude, longitude and a page of trigonometry โ€” no data feed, which is why the sunrise and sunset tool runs entirely on your device. This guide explains what goes into that page and the things about daylight that surprise people every year.

What 'sunrise' means

Sunrise is the moment the upper edge of the Sun appears on a flat horizon โ€” not the centre, and not the geometric position. Two corrections apply: the Sun's disc is about half a degree across, so its top edge shows a quarter-degree before its centre; and atmospheric refraction bends light over the horizon by about 0.57ยฐ, so we see the Sun before it has geometrically risen. Together, published times use the Sun's centre at โˆ’0.833ยฐ below the horizon. Hills, buildings and altitude change what you actually see by minutes; the published figure is the standard flat-horizon one.

Latitude and the seasons

Earth's axis is tilted 23.4ยฐ to its orbit, so the Sun's position against the sky moves between 23.4ยฐ north (June solstice) and 23.4ยฐ south (December solstice) of the celestial equator โ€” its declination. Day length follows from your latitude and that declination: on the equator every day is close to 12 hours; at 50ยฐ north, from about 8 hours in December to 16 in June; above the Arctic Circle (66.6ยฐ) the Sun doesn't rise at midwinter or set at midsummer. Equinoxes give near-12-hour days everywhere โ€” slightly more, because of the refraction and disc-size corrections. Leap years, explained properly covers why the calendar has to keep pace with the tilt's cycle.

Why the earliest sunset isn't the shortest day

In the northern mid-latitudes the earliest sunset comes around 10โ€“13 December and the latest sunrise in early January, straddling the 21 December solstice. The cause is the equation of time: because Earth's orbit is elliptical and its axis tilted, solar noon drifts up to 16 minutes earlier or later than clock noon over the year. In December it is drifting later by about half a minute a day, which pushes both sunrise and sunset later โ€” enough to move the sunset minimum before the solstice and the sunrise maximum after it. The same effect makes the analemma, the figure-of-eight the Sun traces if photographed at the same clock time all year.

Twilight: civil, nautical, astronomical

After sunset the sky stays light while the Sun is just below the horizon. Civil twilight lasts until the Sun is 6ยฐ below โ€” enough light for outdoor activity; it's what "lighting-up time" and many legal definitions use. Nautical twilight ends at 12ยฐ, when the horizon is no longer visible for sextant sights. Astronomical twilight ends at 18ยฐ, when the sky is fully dark. Near the equator these pass in under an hour; at high latitudes in summer, astronomical twilight never ends and the sky never goes truly dark. The tool lists all three.

How the calculation works

The standard algorithm: compute the day of the year; from it the Sun's declination and the equation of time (from series approximations accurate to a minute or so); then solve the sunrise equation, cos(ฯ‰) = (sin(โˆ’0.833ยฐ) โˆ’ sin(ฯ†) sin(ฮด)) รท (cos(ฯ†) cos(ฮด)), where ฯ† is latitude and ฮด declination, for the hour angle ฯ‰; sunrise and sunset are solar noon โˆ“ ฯ‰, and solar noon is 12:00 corrected by the longitude's offset from the time zone's meridian and the equation of time. Convert to local time with the time zone and daylight saving (the time zone converter). The whole thing is a few lines of code; the hard parts are the time zone and what counts as the horizon. The world clock shows where the Sun is up right now; How moon phases work โ€” the geometry behind the 29.5-day cycle the night's other timetable.

Sources and further reading

The claims in this guide rest on these references, which were checked when the guide was last updated. Spotted an error? The contact page says how to report it.

  1. Sunrise equation โ€” Wikipedia

Try the tool

Frequently asked questions

Why isn't the earliest sunset on the shortest day?

Solar noon drifts later through December (the equation of time), pushing sunset's earliest point to around 10โ€“13 December and the latest sunrise into early January, with the solstice between.

What is civil twilight?

The period after sunset (or before sunrise) while the Sun is less than 6ยฐ below the horizon โ€” bright enough for outdoor activity. Nautical ends at 12ยฐ, astronomical at 18ยฐ.

Does the calculator need an internet connection?

No โ€” sunrise and sunset follow from latitude, longitude and the date with a standard formula. Only the time zone is needed to show local time.

Why does my actual sunrise differ from the published time?

Published times assume a flat sea-level horizon. Hills, buildings, altitude and atmospheric conditions shift the visible moment by minutes.