alarm-clock.org/methodology/sunrise-sunset

How sunrise and sunset are calculated

Every time on a sunrise & sunset page is solved in your browser from the page's own latitude and longitude. This is the method, in the order the code does it — and, at the end, what it gets wrong.

The calculation, step by step

1. Days since J2000. The instant is converted to days since noon on 1 January 2000, the epoch the rest of the series is written against.
2. The sun's mean anomaly. Where the sun would be if the Earth's orbit were a circle: M = 357.5291° + 0.98560028° × d.
3. The equation of centre. Three sine terms correct that circle to the real ellipse — 1.9148 sin M + 0.02 sin 2M + 0.0003 sin 3M — which is why the sun runs early in January and late in July.
4. Ecliptic longitude, then declination. Add the longitude of perihelion and half a turn to get the sun's position along the ecliptic, then tilt it by the Earth's axial tilt (23.4397°) to get how far north or south of the equator the sun is that day.
5. Solar noon. The moment the sun crosses your meridian, corrected for the equation of time. Not 12:00 — it can be more than a quarter of an hour either side.
6. The hour angle for the target altitude. Solve for how far from noon the sun sits at the angle you asked for, and place the crossing either side of noon.

Why the horizon is −0.833°, not 0°

Sunrise is not the moment the sun's centre reaches the horizon. Two things happen first. The sun is a disc about half a degree across, so its upper edge clears the horizon while its centre is still below — roughly 0.25°. And the atmosphere bends light coming in at a shallow angle, lifting the whole sun into view before it is geometrically there — about another 0.583° under a standard atmosphere.

Add them and you get the convention this site solves for: the sun's centre at 0.833° below the true horizon. It is the same number almanacs use, which is why the times agree with them.

The refraction half of that is an average. Real bending depends on air temperature and pressure, and over cold water or in a strong inversion it can differ enough to move visible sunrise by a couple of minutes. Nothing on this site models that, and nothing reasonably could without local atmospheric data.

The twilights are the same solve, at a different angle

Once you can solve for "when is the sun at angle X", every twilight is the same calculation with a different X — which is exactly how the page produces them.

Sunrise / sunset−0.833°
Civil twilight — first and last light, bright enough to read outside−6°
Nautical twilight — the sea horizon is still visible−12°
Astronomical twilight — true darkness for stargazing−18°
Golden hour — warm, low-angle light−4° to +6°
Blue hour — the deep blue band just past it−6° to −4°

At high latitudes in summer the sun never gets that low, so there is no crossing to report. The page shows a dash and says the twilight does not end, rather than inventing a time.

What this method does not model

Your elevation. Stand on a hill and you see the sun earlier than someone at sea level below you. The calculation assumes a flat sea-level horizon.
The terrain. A mountain to the east delays sunrise by however long it takes the sun to clear it. That is local geography, not astronomy, and no formula here knows about it.
Non-standard refraction. The 0.583° above is an average, not your air.
Nutation and aberration. The Earth's axis wobbles slightly and light takes time to arrive; both are omitted. Together they are worth well under the error already measured below.
The declination changing during the day. The solver treats the sun's declination as fixed for the day and places sunrise and sunset symmetrically either side of solar noon. It moves. This is the largest of the simplifications, and it is the one measured next.

How far off is it? Measured, not asserted

The closed-form solve above is fast enough to run for a thousand cities in a browser, which is why it is used. To find what that speed costs, a script kept with the site’s source (seo/tools/measure-sun.mjs) re-solves the same horizon crossing iteratively — stepping until the sun's actual computed altitude equals −0.833° — and compares.

Comparisons48
Latitudes tested0°, 20°, 40°, 51.5°, 60°, 65°
Dates testedboth equinoxes, both solstices
Typical difference1.0 minutes
Worst difference1.9 minutes (at 65°, 2026-09-22)

The pattern is the one you would expect: the difference is smallest near the equinoxes at low latitudes and grows toward the poles, where the sun's path meets the horizon at a shallow angle and a small error in altitude becomes a large error in time.

What this figure is not. Both sides of that comparison use the same solar-position series, so it bounds the solver and says nothing about the astronomy underneath it. And it cannot see the four things in the section above, which are not modelled at all. Treat it as the floor of the error, not the ceiling.

Related

Sunrise & sunset times · How the moon phase is calculated · How time zones and DST are handled

💡 How do we make alarm-clock.org better? Share an idea →

Every tool here is free, needs no sign-up, and gets better because people tell us what's missing. If you have an idea, we'd love to hear it.

Every suggestion is read and reviewed. We can't promise to act on them all, but they directly shape what we build next.