Sunset Calculator

Enter a date, latitude, longitude, and UTC time zone offset to compute the local sunset time using the sun's declination and hour angle.

Quick Facts

Sunset zenith angle
90.833° (90°50′)
Standard sunset is defined at this zenith angle to account for atmospheric refraction (~34′) and the sun's angular radius (~16′).
Solar declination range
-23.45° to +23.45°
The sun's declination swings between the tropics across the year, which is why sunset time shifts with the seasons.
Hour angle rate
15° per hour
Earth's rotation moves the sun's hour angle 15° every hour, so hour angle divided by 15 gives hours from solar noon.
Polar day/night
Beyond ±66.5° latitude
Above the Arctic/Antarctic Circle, the sun can stay up all day (midnight sun) or never rise (polar night) near the solstices.

Your Results

Calculated
Sunset Time (Local)
-
Clock time at your UTC offset
Solar Declination
-
Sun's angle relative to the celestial equator, in degrees
Hour Angle at Sunset
-
Angular distance from solar noon, in degrees
Day of Year
-
Day number (1-365/366) used in the calculation

Ready

Enter a date and location, then press Calculate.

Formula and Method for Sunset Time

Sunset happens when the sun's center drops to a zenith angle of 90.833° below the local vertical — slightly more than a literal 90° because atmospheric refraction lifts the sun's apparent position by about 34 arcminutes and the sun's disk has a radius of about 16 arcminutes, so the upper limb is still visible when the geometric center is already below the horizon. This calculator implements the classic sunrise/sunset algorithm published by the U.S. Naval Observatory's Nautical Almanac Office (Almanac for Computers, 1990), which finds sunset from three quantities: the sun's ecliptic longitude on a given day, its declination δ (angle north or south of the celestial equator), and the local hour angle H at which the sun reaches the 90.833° zenith for your latitude.

How the calculation works

The algorithm proceeds in steps. First it converts your date to a day-of-year number N and your longitude to an hour offset (lngHour = longitude ÷ 15) to estimate an approximate time of sunset. From that it computes the sun's mean anomaly M and true ecliptic longitude L, then the sun's declination via sinδ = 0.39782 × sin(L). The local hour angle at sunset comes from cos H = [cos(90.833°) − sinδ×sin(latitude)] / [cosδ×cos(latitude)], solved as H = arccos(cos H). Converting H to hours (H ÷ 15) and combining it with the sun's right ascension gives the mean local time of sunset in Universal Time, which is then shifted by your entered UTC offset to produce a clock time you can read directly. If cos H falls outside [−1, 1], there is no valid sunset that day — the sun is either continuously up (cos H < −1) or never rises (cos H > 1), which happens only at high latitudes near the solstices.

Time zones, longitude sign, and daylight saving

Longitude is entered as positive for east and negative for west of the prime meridian (so New York is roughly −74° and Tokyo is roughly +140°). The UTC offset should reflect your actual local clock, including daylight saving time if it is in effect on the date you enter — for example, New York is UTC−5 in winter (EST) but UTC−4 in summer (EDT). Getting the offset wrong shifts the answer by whole hours even though the underlying astronomy is unaffected.

Accuracy and what this calculator does not model

This algorithm is accurate to roughly a minute for most dates and latitudes under standard atmospheric conditions. It does not account for your local horizon — hills, buildings, or trees can hide the sun before the geometric sunset time, and being at elevation (a mountain, a tall building) can expose the sun a little longer than the flat-horizon calculation predicts. Unusual atmospheric refraction (temperature inversions, extreme cold, or high humidity) can also shift the true horizon crossing by a minute or two from the standard prediction.

Frequently Asked Questions

What formula does this sunset calculator use?
It uses the classic sunrise/sunset algorithm from the U.S. Naval Observatory's Nautical Almanac Office, which computes the sun's declination and local hour angle for a zenith angle of 90.833° (the standard definition of sunset that accounts for atmospheric refraction and the sun's angular size), then converts the result to your local clock time.
Why do I need to enter longitude and a UTC offset separately?
Longitude fixes your position relative to the sun's apparent motion and is used inside the astronomical calculation. The UTC offset is a separate, human convention — it converts the calculated Universal Time of sunset into whatever clock time your time zone (and daylight saving rule) actually uses.
How accurate is the calculated sunset time?
Typically within about a minute of published almanac values under normal atmospheric conditions. Local terrain, elevation, and unusual refraction can shift the moment the sun visually disappears by a minute or two from this geometric prediction.
What does it mean if the calculator says the sun never sets or never rises?
This occurs only at latitudes beyond about 66.5° (inside the Arctic or Antarctic Circle) around the summer or winter solstice. Near the summer solstice the sun can stay above the horizon all day ("midnight sun"); near the winter solstice it can stay below the horizon all day (polar night).