ユーティリティ

How Sunrise and Sunset Times Are Calculated

How we calculate sunrise, sunset, golden hour, and twilight times using Jean Meeus's astronomical algorithms.

Verified against Jean Meeus, Astronomical Algorithms, 2nd Edition on 4 Mar 2026 Updated 4 March 2026 3 min read
計算ツールを開く

Translation unavailable - this article is shown in English. View English version

Summary

The sunrise/sunset calculator computes the exact times of sunrise, sunset, solar noon, golden hour, and three twilight phases for any date and location on Earth. These times matter to a wide range of people: photographers planning golden-hour shoots, travellers adjusting to new latitudes, pilots and sailors observing twilight rules, hikers timing daylight, and astronomers waiting for true darkness.

The engine implements the solar position algorithms from Jean Meeus’s Astronomical Algorithms (2nd Edition), the standard reference for positional astronomy. Given a date, latitude, and longitude, it calculates where the sun is in the sky and when it crosses key altitude thresholds.

How it works

Why sunrise and sunset change

Two facts about the Earth drive the variation in sunrise and sunset times:

  1. Axial tilt (23.44 degrees): The Earth’s axis is tilted relative to its orbital plane. In summer, your hemisphere tilts toward the sun, giving longer days. In winter, it tilts away, giving shorter days.
  2. Elliptical orbit: The Earth’s orbit is slightly elliptical, so it moves faster when closer to the sun (January) and slower when farther away (July). This affects the timing of solar noon.

At the equator, day length barely changes throughout the year. At the poles, it swings from 24 hours of daylight to 24 hours of darkness.

Step 1: Julian Day conversion

Astronomical calculations need a continuous day count rather than our calendar system (which has irregular months, leap years, and timezone offsets). The Julian Day Number (JD) counts days from 1 January 4713 BC. For example, 1 January 2000 at noon UTC is JD 2,451,545.0 — this epoch is called J2000.0, and all modern astronomical formulas use it as a reference point.

The Julian Century (T) measures time in centuries since J2000.0:

T = (JD - 2,451,545.0) / 36,525

Step 2: Solar position parameters

Using T, the engine computes several quantities that describe where the sun is:

  • Mean longitude (L0): The sun’s average position along the ecliptic, ignoring orbital irregularities.
  • Mean anomaly (M): How far the Earth is along its elliptical orbit from its closest approach to the sun (perihelion).
  • Equation of centre (C): A correction to the mean anomaly that accounts for the elliptical orbit. The sun appears to speed up and slow down as the Earth moves closer to and farther from it.
  • Apparent longitude: The sun’s corrected position on the ecliptic, adjusted for nutation (a wobble in the Earth’s axis) and aberration (the effect of the Earth’s orbital velocity on the apparent direction of light).

Step 3: Solar declination

The declination is the sun’s latitude above or below the celestial equator, measured in degrees. It ranges from +23.44 degrees at the June solstice to -23.44 degrees at the December solstice. Declination is the primary driver of seasonal day-length changes: when the sun’s declination matches your latitude, the sun passes nearly overhead.

Step 4: Equation of Time

The Equation of Time (EoT) is the difference between “sundial time” (apparent solar time) and “clock time” (mean solar time). It varies by up to plus or minus 16 minutes throughout the year because of the combined effects of the Earth’s axial tilt and elliptical orbit. The engine uses EoT to calculate the exact minute when the sun crosses the local meridian (solar noon):

Solar noon (minutes from midnight UTC) = 720 - EoT - longitude x 4

Each degree of longitude shifts solar noon by 4 minutes (since the Earth rotates 360 degrees in 1,440 minutes).

Step 5: Hour angle

The hour angle (H) is the angular distance of the sun from the meridian at the moment it crosses a specific altitude. For sunrise and sunset, the target altitude is -0.833 degrees. The hour angle is found by:

cos(H) = (sin(altitude) - sin(lat) x sin(dec)) / (cos(lat) x cos(dec))

If the result is between -1 and 1, the sun rises and sets normally. If cos(H) > 1, the sun never reaches that altitude (polar night). If cos(H) < -1, the sun never drops below that altitude (midnight sun).

Once H is known, sunrise and sunset are simply solar noon minus or plus the hour angle converted to minutes (1 degree = 4 minutes).

The -0.833 degree correction

The standard altitude for sunrise and sunset is not zero degrees. Two effects push the visible sunrise earlier and sunset later:

  • Atmospheric refraction (+0.567 degrees): The atmosphere bends light, making the sun appear higher than it geometrically is. At the horizon, refraction lifts the sun’s image by about 34 arcminutes.
  • Sun’s apparent diameter (+0.266 degrees): Sunrise is defined as when the upper edge of the sun (not its centre) touches the horizon, which adds another 16 arcminutes.

Combined, the correction is 0.833 degrees below the geometric horizon.

Golden hour explained

Golden hour is the period when the sun is between -4 and 6 degrees altitude. During this window, sunlight travels through more of the atmosphere, scattering shorter blue wavelengths and letting warm red and orange tones dominate. Shadows are long, contrast is soft, and the light has a distinctive warm quality.

This is why photographers and filmmakers prize golden hour: portraits have flattering skin tones, landscapes glow, and the low angle creates dramatic depth. The morning golden hour begins before sunrise (when the sun is still below the horizon) and extends into early morning. The evening golden hour begins in late afternoon and continues past sunset.

The calculator computes both windows by finding the times when the sun crosses -4 degrees (below horizon) and 6 degrees (above horizon).

Twilight phases

After the sun sets, the sky does not immediately go dark. Three progressively deeper stages of twilight are defined by how far below the horizon the sun has dropped:

Civil twilight (sun between 0 and -6 degrees)

There is enough natural light for most outdoor activities without artificial lighting. Car headlights are typically required by law at the end of civil twilight. This is the brightest phase of twilight.

Nautical twilight (sun between -6 and -12 degrees)

The horizon is still visible at sea, allowing navigators to take star sightings against a defined horizon line. On land, the sky is noticeably dark but not fully black.

Astronomical twilight (sun between -12 and -18 degrees)

The sky is dark enough for most astronomical observations. Below -18 degrees, the sun contributes no measurable illumination, and the sky is considered fully dark. This is the threshold that astronomers and stargazers watch for.

The calculator reports the dawn and dusk time for each phase.

Polar edge cases

At extreme latitudes, the standard hour-angle formula breaks down because the sun may never rise or never set:

  • Midnight sun: During summer at latitudes above the Arctic Circle (66.56 degrees N) or below the Antarctic Circle (66.56 degrees S), the sun stays above -0.833 degrees for the entire day. The calculator reports this as “midnight sun” with a day length of 24 hours.
  • Polar night: During winter at the same latitudes, the sun never climbs above -0.833 degrees. The calculator reports this as “polar night” with a day length of 0 hours.

The Arctic and Antarctic Circles (approximately 66.56 degrees latitude) mark the boundary where these phenomena begin on the solstices. In practice, atmospheric refraction extends the zone slightly — locations a fraction of a degree below the circle can still experience midnight sun.

The engine detects these cases mathematically: when cos(H) falls outside the range [-1, 1], no valid hour angle exists, and the appropriate polar flag is set.

Worked example

London, 21 June 2026 (summer solstice)

Inputs:

  • Latitude: 51.5074 degrees N
  • Longitude: -0.1278 degrees (0.1278 degrees W)

Key outputs (approximate, BST = UTC+1):

OutputTime (BST)
Sunrise~04:43
Sunset~21:21
Solar noon~13:02
Day length~16h 38min
Golden hour (morning)~04:15 to ~05:30
Golden hour (evening)~20:30 to ~21:50
Civil twilight dawn~04:00
Civil twilight dusk~22:05
Nautical twilight dawn~02:45
Nautical twilight dusk~23:20

At this latitude on the longest day, London gets over 16.5 hours of daylight. Astronomical twilight never fully ends — the sky never reaches full darkness, a phenomenon known as the “bright nights” of midsummer.

Inputs explained

  • Date — The calendar date for the calculation. Sunrise and sunset shift by a minute or two each day (more around the equinoxes, less around the solstices).
  • Latitude — Your north-south position in degrees. Positive values are north of the equator, negative values are south. London is 51.5 degrees N; Sydney is -33.9 degrees.
  • Longitude — Your east-west position in degrees. Positive values are east of the Prime Meridian, negative values are west. London is -0.13 degrees; New York is -74.0 degrees.
  • Geolocation — Uses your browser’s location API to fill in latitude and longitude automatically. Requires location permission.

Outputs explained

  • Sunrise / Sunset — The times when the upper edge of the sun crosses the horizon, corrected for atmospheric refraction.
  • Solar noon — The moment the sun reaches its highest point in the sky (crosses the local meridian). This is not always 12:00 due to the Equation of Time and timezone offsets.
  • Day length — The duration from sunrise to sunset in hours and minutes.
  • Golden hour (morning / evening) — The time windows when the sun is between -4 and 6 degrees altitude, producing warm, soft light.
  • Civil / Nautical / Astronomical twilight — Dawn and dusk times for each twilight phase, defined by the sun’s depression angle below the horizon.
  • Maximum altitude — The sun’s highest angle above the horizon at solar noon. At London on the summer solstice, this is roughly 62 degrees.
  • Altitude — The sun’s angle above (or below) the horizon at the currently selected time. Updates in real time as you drag the sun along the arc.
  • Azimuth — The compass direction of the sun at the currently selected time, in degrees clockwise from north, with a 16-point compass label.
  • Midnight sun / Polar night — Flags indicating whether the sun never sets or never rises on the given date at the given latitude.

Altitude and azimuth

The calculator shows two additional quantities that describe where the sun is in the sky at any given moment:

  • Altitude (elevation angle) — the angle between the sun and the horizon, measured in degrees. 0 degrees means the sun is on the horizon, 90 degrees means directly overhead (zenith), and negative values mean below the horizon. The formula is:

sin(altitude) = sin(lat) × sin(dec) + cos(lat) × cos(dec) × cos(H)

where H is the hour angle — the angular distance of the sun from the local meridian, computed from the time of day, the Equation of Time, and the observer’s longitude.

  • Azimuth — the compass direction of the sun, measured in degrees clockwise from north (0 = N, 90 = E, 180 = S, 270 = W). Computed using the numerically stable atan2 formula:

azimuth = atan2(-cos(dec) × sin(H), sin(dec) × cos(lat) - cos(dec) × sin(lat) × cos(H))

The calculator displays the azimuth as both a degree value and a 16-point compass label (N, NNE, NE, ENE, E, etc.).

Interactive arc visualisation

The arc chart plots the sun’s actual computed altitude against time of day, from midnight to midnight. Unlike a decorative parabola, this curve reflects the true solar geometry for the chosen date and location. The arc is colour-coded by altitude:

  • Blue (above 6 degrees) — full daytime
  • Amber (-4 to 6 degrees) — golden hour zone
  • Dashed lines (below -4 degrees) — twilight and night, coloured by phase

Dragging the sun disc along the arc updates the altitude, azimuth, compass bearing, and sky gradient in real time, allowing you to explore exactly where the sun will be at any time of day.

Assumptions & limitations

  • Standard atmospheric refraction is assumed (0.833 degrees total correction). Actual refraction varies with temperature, pressure, and humidity. In extreme cold, refraction can be significantly larger.
  • Flat horizon at sea level. The calculator assumes an unobstructed horizon. Mountains, buildings, and elevated terrain can delay sunrise and advance sunset by several minutes.
  • Accuracy: Within 1-2 minutes for most locations, verified against US Naval Observatory data. The Meeus algorithms are accurate to about 0.01 degrees of solar position.
  • No terrain modelling. Observer elevation is not considered. At higher altitudes, the visible horizon is slightly lower, which extends the day by a small amount.
  • Timezone handling: All internal calculations are in UTC. The displayed local times depend on the user’s browser timezone or a manually selected offset.

出典

astronomy sunrise sunset golden hour twilight