Skip to content

Sunrise, sunset and twilight calculator

Algorithm: NOAA solar position equations. Accuracy: ±1 minute for most locations.

What the four twilight phases mean

  • Sunrise / sunset — the upper limb of the Sun crosses the horizon. Sun altitude is −0.833° (accounting for atmospheric refraction).
  • Civil twilight (−6°) — bright enough to read outdoors, brightest stars appear.
  • Nautical twilight (−12°) — horizon still visible at sea, navigation by stars possible.
  • Astronomical twilight (−18°) — sky fully dark, ideal for deep-sky observation.

How the calculation works

The script computes solar declination and the equation of time from the date, then solves the hour-angle equation for the latitude. It uses the NOAA solar position algorithm, accurate to about 1 minute between latitudes 70° N and 70° S. Within the Arctic and Antarctic circles, polar day or night will return "—" for events that do not occur.

What the calculator does not include

It does not account for terrain (mountains and tall buildings on your horizon), local atmospheric pressure or temperature anomalies (which slightly bend light), or daylight saving transitions on the displayed day. For aviation or surveying precision, use the US Naval Observatory tables.