Astronomy

How Sunrise and Sunset Times Are Actually Calculated

The geometry, atmospheric physics, and algorithms behind sunrise and sunset calculations — including why the Sun is already below the horizon when you see it rise.

DM
Dr. Meera Iyer

Astrophysicist

17. Februar 2026·7 Min. Lesezeit

The Sun You See Has Already Set

Here's a fact that surprises most people: when you watch the Sun touch the horizon at sunset, it's already geometrically below it. Earth's atmosphere bends light, and this refraction "lifts" the Sun's image by about 0.57° — roughly the Sun's own diameter. So at the moment of geometric sunset, you're seeing a mirage of the Sun. This adds about 2 minutes of extra visible sunlight at mid-latitudes, and even more near the poles where the Sun's path is shallower.

The same thing happens in reverse at sunrise. You see the Sun before it's geometrically above the horizon. So every "sunrise" you've ever watched started a couple of minutes early, and every "sunset" lingered a couple of minutes late. The atmosphere is giving you free daylight — roughly 4-5 extra minutes per day at 40°N latitude. At the poles, where the Sun's angle of approach to the horizon is extremely shallow, refraction can add days of extra visible sunlight around the equinoxes.

The Core Geometry

At its heart, sunrise and sunset calculation is a geometry problem. You need three inputs: your latitude, the Sun's declination (its angular position north or south of the celestial equator, which changes throughout the year due to Earth's axial tilt), and the hour angle — how far the Sun is from the local meridian.

The standard formula for the hour angle at sunrise/sunset is:

cos(hour_angle) = -tan(latitude) x tan(declination)

When this equation has no solution (the right side exceeds 1 or -1), the Sun either never sets (midnight sun) or never rises (polar night). Convert the hour angle to time, adjust for the equation of time and your longitude, and you've got a basic sunrise/sunset time.

Let me walk through a concrete example. On March 20 (near the equinox), the Sun's declination is roughly 0°. The tangent of 0° is 0, so the formula simplifies to cos(hour_angle) = 0, which gives an hour angle of 90°. Since 90° corresponds to 6 hours of solar time, the Sun rises 6 hours before solar noon and sets 6 hours after — exactly 12 hours of daylight. That's the equinox, and the math confirms it. On June 21 at 40°N, the Sun's declination is about 23.44°. Plug that in: cos(h) = -tan(40°) × tan(23.44°) = about -0.364, which gives an hour angle of about 111.3°, or 7 hours 25 minutes before and after solar noon — roughly 14 hours 50 minutes of daylight. Add refraction corrections and you get close to the 15-hour figure in practice.

Why Your Longitude Matters (and How Timezones Obscure It)

Sunrise and sunset times depend on your longitude within your timezone, and the effect is larger than most people realize. A timezone typically spans 15° of longitude. If you're on the eastern edge, the Sun reaches your meridian earlier than the clock says "noon." On the western edge, it arrives later.

Take the US Eastern Time zone. Boston (71.1°W) and Detroit (83.0°W) are in the same timezone, but Detroit is nearly 12° farther west. That translates to about 48 minutes of difference in solar time. On the winter solstice, sunset in Boston is around 4:14 PM, while in Detroit it's about 5:00 PM. Same timezone, 46 minutes apart. If you've ever moved east within your timezone and wondered why sunset felt shockingly early, this is the reason — the clock didn't change, but the Sun's relationship to your local noon did.

China takes this to an extreme. The entire country uses a single timezone (UTC+8), despite spanning roughly 60° of longitude. In Kashgar in western China, solar noon doesn't arrive until about 2:00 PM by the clock. Sunrise in mid-winter can be after 10:00 AM. Locals informally use their own "Xinjiang time" (UTC+6), but all official schedules run on Beijing time.

Three Types of Twilight

Sunset doesn't mean instant darkness. There are three officially defined twilight periods, based on how far the Sun is below the horizon:

  • Civil twilight: Sun is 0° to 6° below the horizon. There's still enough light for most outdoor activities without artificial lighting. This is when car headlights become legally required in many jurisdictions.
  • Nautical twilight: 6° to 12° below. The horizon is still visible at sea — hence the name. Sailors could historically use it for celestial navigation.
  • Astronomical twilight: 12° to 18° below. Faint stars become visible, but the sky isn't fully dark. Once the Sun drops past 18°, true night begins.

The practical impact: at 50°N latitude in June, the Sun never drops more than about 16° below the horizon. That means astronomical twilight never fully ends — there's no true "night" for weeks around the summer solstice. Astronomers in Edinburgh or Copenhagen can't do deep-sky observation in midsummer. At 60°N (Helsinki, Anchorage), the Sun doesn't get past 6° below the horizon in June, so civil twilight persists all night. It never gets truly dark. Conversely, near the equator, all three twilight stages blow through in about 70 minutes total. The Sun drops fast, and night arrives abruptly.

The Equation of Time

If Earth's orbit were perfectly circular and its axis weren't tilted, solar noon would happen at the same clock time every day. But Earth's orbit is elliptical, and the axis is tilted. These two factors combine to make the Sun arrive at the meridian up to 16 minutes early or 14 minutes late compared to "mean" solar time. This variation is called the equation of time, and it's why sunrise and sunset times don't change symmetrically — sunset can start getting later while sunrise is still getting later too.

The equation of time produces a figure-eight pattern called an analemma — if you photograph the Sun's position at the same clock time every day for a year, the resulting trail of dots traces this shape. The vertical axis of the analemma shows the Sun's declination (higher in summer, lower in winter). The horizontal spread shows the equation of time — how much the Sun deviates from the "average" east-west position. Sundials in parks and public spaces sometimes include an analemma correction table so you can read the true clock time from the shadow.

The two contributing factors peak at different times. The eccentricity effect (Earth moves faster when closer to the Sun in January, slower in July) peaks around early January and early July. The obliquity effect (the tilt makes the Sun's apparent east-west motion uneven) peaks around the equinoxes and solstices. These two sine-like curves add together to produce the lumpy, asymmetric equation of time curve, with the largest deviation (Sun about 16 minutes early) in early November and the other extreme (about 14 minutes late) in mid-February.

Elevation and Terrain

The standard sunrise/sunset calculation assumes a flat horizon at sea level. Real life isn't that tidy. If you're standing on a mountain, your effective horizon is lower — you can see farther "over the edge" of the curved Earth — so you see sunrise earlier and sunset later. The correction is roughly 1 minute of extra daylight per 300 meters of elevation. A person at 1,500 meters (Denver's elevation) sees sunrise about 5 minutes earlier than someone at sea level at the same latitude and longitude.

Terrain matters even more in practice. A valley surrounded by mountains will have a much later apparent sunrise (the Sun has to clear the mountain ridge) and earlier sunset than the geometric prediction. Coastal cities with an unobstructed western ocean horizon enjoy textbook sunsets. Inland cities with hills or buildings blocking the horizon don't. The algorithms give you the astronomical time — what you'd see with a perfectly flat, unobstructed horizon. Your local experience may differ by several minutes.

Modern Algorithms

Serious astronomical software uses the Solar Position Algorithm (SPA) developed by NREL (National Renewable Energy Laboratory). It accounts for Earth's orbital eccentricity, axial tilt, precession, nutation, atmospheric refraction, and observer elevation. The SPA is accurate to within ±0.0003° from -2000 to 6000 CE — far more precision than anyone needs for daily sunrise/sunset times, but essential for applications like solar energy and architectural planning.

Most online calculators (including ours) use a simplified version of these algorithms that's accurate to about ±1 minute for typical locations. Good enough for planning your morning run.

For developers implementing sunrise/sunset calculations, the most common approach is Jean Meeus's algorithms from Astronomical Algorithms. The book provides step-by-step procedures for computing solar declination, the equation of time, hour angles, and refraction corrections. The calculations are pure math — trigonometry and orbital mechanics — with no API calls or external dependencies needed. Our own sun calculator uses a TypeScript implementation of these formulas, and the entire module is about 200 lines of code. Solar position is one of those problems where the math is well-understood and stable — the same algorithms work for any date in any century.

Frequently Asked Questions

Why does the sunrise time change every day?

Because Earth's axial tilt means the Sun's declination (its position relative to the equator) changes continuously as Earth orbits. This shifts the geometry of sunrise/sunset. The equation of time, caused by Earth's elliptical orbit, adds additional variation.

What is civil twilight?

Civil twilight is the period when the Sun is between 0° and 6° below the horizon. There's still enough ambient light for most outdoor activities. It typically lasts 20-40 minutes depending on latitude and season.

How accurate are online sunrise and sunset calculators?

Most reputable calculators are accurate to within 1-2 minutes for typical locations. The main sources of error are local terrain (mountains or buildings blocking the horizon), unusual atmospheric conditions, and observer elevation. Flat-horizon, sea-level calculations are the most accurate.

What is atmospheric refraction and how does it affect sunrise?

Atmospheric refraction is the bending of light as it passes through Earth's atmosphere. It causes the Sun to appear about 0.57° higher than its true geometric position, adding roughly 2 minutes of visible sunlight at mid-latitudes. You see the Sun before it has actually risen above the horizon.

What is the equation of time?

The equation of time is the difference between apparent solar time (based on the Sun's actual position) and mean solar time (based on a hypothetical uniform Sun). It varies by up to 16 minutes throughout the year, caused by Earth's elliptical orbit and axial tilt.

What are the three types of twilight?

Civil twilight (Sun 0°-6° below horizon) provides enough light for outdoor activities. Nautical twilight (6°-12° below) allows sailors to see the horizon. Astronomical twilight (12°-18° below) is when faint stars appear. True night begins when the Sun is more than 18° below the horizon.

Does elevation affect sunrise and sunset times?

Yes. Higher elevations see sunrise earlier and sunset later because the observer can see farther over the curved horizon. A person at 1,000 meters elevation may see sunrise about 3 minutes earlier than someone at sea level at the same latitude and longitude.

Sources

  • Reda, I. & Andreas, A. "Solar Position Algorithm for Solar Radiation Applications," NREL Technical Report (2003, revised 2008)
  • Meeus, Jean. Astronomical Algorithms, 2nd Edition (1998)
  • NOAA Solar Calculator (gml.noaa.gov/grad/solcalc)

DM

Über den Autor

Dr. Meera Iyer

Astrophysicist

Dr. Meera Iyer completed her PhD in Astrophysics and spent eight years working on precision timekeeping and solar observation. She has published over 30 peer-reviewed papers on astronomical time measurement, contributed to navigation satell

Vollständige Bio lesen →
Zurück zum Blog

Verwandte Artikel