Sunset
Sunset (or sundown) is the disappearance of the Sun below the horizon due to Earth's rotation. As viewed from everywhere on Earth, it is a phenomenon that happens once every 24 hours except in areas close to the poles. The equinox Sun sets due west at the moment of both the spring and autumn equinoxes. As viewed from the Northern Hemisphere, the Sun sets to the northwest (or not at all) in the spring and summer, and to the southwest in the autumn and winter; these seasons are reversed for the Southern Hemisphere.
The time of sunset is defined in astronomy as the moment when the upper limb of the Sun disappears below the horizon. Near the horizon, atmospheric refraction causes sunlight rays to be distorted to such an extent that geometrically the solar disk is already about one diameter below the horizon when a sunset is observed.
Sunset is distinct from twilight, which is divided into three stages. The first one is civil twilight, which begins once the Sun has disappeared below the horizon, and continues until it descends to 6 degrees below the horizon. The second phase is nautical twilight, between 6 and 12 degrees below the horizon. The third phase is astronomical twilight, which is the period when the Sun is between 12 and 18 degrees below the horizon. Dusk is at the very end of astronomical twilight, and is the darkest moment of twilight just before night. Finally, night occurs when the Sun reaches 18 degrees below the horizon and no longer illuminates the sky.Locations further north than the Arctic Circle and further south than the Antarctic Circle experience no full sunset or sunrise on at least one day of the year, when the polar day or the polar night persists continuously for 24 hours. At latitudes greater than within half a degree of either pole, the sun cannot rise or set on the same date on any day of the year, since the sun's angular elevation between solar noon and midnight is less than one degree.

Occurrence
The time of sunset varies throughout the year, and is determined by the viewer's position on Earth, specified by latitude and longitude, altitude, and time zone. Small daily changes and noticeable semi-annual changes in the timing of sunsets are driven by the axial tilt of the Earth, daily rotation of the Earth, the planet's movement in its annual elliptical orbit around the Sun, and the Earth and Moon's paired revolutions around each other. During winter and spring, the days get longer and sunsets occur later every day until the day of the latest sunset, which occurs after the summer solstice. In the Northern Hemisphere, the latest sunset occurs late in June or in early July, but not on the summer solstice of June 21. This date depends on the viewer's latitude (connected with the Earth's slower movement around the aphelion around July 4). Likewise, the earliest sunset does not occur on the winter solstice, but rather about two weeks earlier, again depending on the viewer's latitude. In the Northern Hemisphere, it occurs in early December or late November (influenced by the Earth's faster movement near its perihelion, which occurs around January 3).Likewise, the same phenomenon exists in the Southern Hemisphere, but with the respective dates reversed, with the earliest sunsets occurring some time before June 21 in winter, and latest sunsets occurring some time after December 21 in summer, again depending on one's southern latitude. For a few weeks surrounding both solstices, both sunrise and sunset get slightly later each day. Even on the equator, sunrise and sunset shift several minutes back and forth through the year, along with solar noon. These effects are plotted by an analemma.Neglecting atmospheric refraction and the Sun's non-zero size, whenever and wherever sunset occurs, it is always in the northwest quadrant from the March equinox to the September equinox, and in the southwest quadrant from the September equinox to the March equinox. Sunsets occur almost exactly due west on the equinoxes for all viewers on Earth. Exact calculations of the azimuths of sunset on other dates are complex, but they can be estimated with reasonable accuracy by using the analemma.As sunrise and sunset are calculated from the leading and trailing edges of the Sun, respectively, and not the center, the duration of a daytime is slightly longer than nighttime (by about 10 minutes, as seen from temperate latitudes). Further, because the light from the Sun is refracted as it passes through the Earth's atmosphere, the Sun is still visible after it is geometrically below the horizon. Refraction also affects the apparent shape of the Sun when it is very close to the horizon. It makes things appear higher in the sky than they really are. Light from the bottom edge of the Sun's disk is refracted more than light from the top, since refraction increases as the angle of elevation decreases. This raises the apparent position of the bottom edge more than the top, reducing the apparent height of the solar disk. Its width is unaltered, so the disk appears wider than it is high. (In reality, the Sun is almost exactly spherical.) The Sun also appears larger on the horizon, an optical illusion, similar to the moon illusion.Locations north of the Arctic Circle and south of the Antarctic Circle experience no sunset or sunrise at least one day of the year, when the polar day or the polar night persist continuously for 24 hours.

Location on the horizon
Approximate locations of sunset on the horizon (azimuth) as described above can be found in Refs.
The figure on the right is calculated using the solar geometry routine as follows:
For a given latitude and a given date, calculate the declination of the Sun using 
  
    
      
        
          0
          
            ∘
          
        
      
    
    {\displaystyle 0^{\circ }}
   longitude and solar noon time as inputs to the routine;
Calculate the sunset hour angle using the sunset equation;
Calculate the sunset time, which is the solar noon time plus the sunset hour angle in degree divided by 15;
Use the sunset time as input to the solar geometry routine to get the solar azimuth angle at sunset.An interesting feature in the figure on the right is apparent hemispheric symmetry in regions where daily sunrise and sunset actually occur. This symmetry becomes clear if the hemispheric relation in sunrise equation is applied to the x- and y-components of the solar vector presented in Ref.

Colors
As a ray of white sunlight travels through the atmosphere to an observer, some of the colors are scattered out of the beam by air molecules and airborne particles, changing the final color of the beam the viewer sees.
Because the shorter wavelength components, such as blue and green, scatter more strongly, these colors are preferentially removed from the beam. At sunrise and sunset, when the path through the atmosphere is longer, the blue and green components are removed almost completely, leaving the longer wavelength orange and red hues we see at those times. The remaining reddened sunlight can then be scattered by cloud droplets and other relatively large particles to light up the horizon red and orange. The removal of the shorter wavelengths of light is due to Rayleigh scattering by air molecules and particles much smaller than the wavelength of visible light (less than 50 nm in diameter).  The scattering by cloud droplets and other particles with diameters comparable to or larger than the sunlight's wavelengths (> 600 nm) is due to Mie scattering and is not strongly wavelength-dependent.  Mie scattering is responsible for the light scattered by clouds, and also for the daytime halo of white light around the Sun (forward scattering of white light).Sunset colors are typically more brilliant than sunrise colors, because the evening air contains more particles than morning air. Sometimes just before sunrise or after sunset a green flash can be seen.Ash from volcanic eruptions, trapped within the troposphere, tends to mute sunset and sunrise colors, while volcanic ejecta that is instead lofted into the stratosphere (as thin clouds of tiny sulfuric acid droplets), can yield beautiful post-sunset colors called afterglows and pre-sunrise glows. A number of eruptions, including those of Mount Pinatubo in 1991 and Krakatoa in 1883, have produced sufficiently high stratus clouds containing sulfuric acid to yield remarkable sunset afterglows (and pre-sunrise glows) around the world. The high altitude clouds serve to reflect strongly reddened sunlight still striking the stratosphere after sunset, down to the surface.
Some of the most varied colors at sunset can be found in the opposite or eastern sky after the Sun has set during twilight. Depending on weather conditions and the types of clouds present, these colors have a wide spectrum, and can produce unusual results.

Names of compass points
In some languages, points of the compass bear names etymologically derived from words for sunrise and sunset. The English words "orient" and "occident", meaning "east" and "west", respectively, are descended from Latin words meaning "sunrise" and "sunset". The word "levant", related e.g. to French "(se) lever" meaning "lift" or "rise" (and also to English "elevate"), is also used to describe the east. In Polish, the word for east wschód (vskhud), is derived from the morpheme "ws" – meaning "up", and "chód" – signifying "move" (from the verb chodzić – meaning "walk, move"), due to the act of the Sun coming up from behind the horizon. The Polish word for west, zachód (zakhud), is similar but with the word "za" at the start, meaning "behind", from the act of the Sun going behind the horizon. In Russian, the word for west, запад (zapad), is derived from the words за – meaning "behind", and пад – signifying "fall" (from the verb падать – padat'), due to the act of the Sun falling behind the horizon. In Hebrew, the word for east is 'מזרח', which derives from the word for rising, and the word for west is 'מערב', which derives from the word for setting.

Historical view
The 16th-century astronomer Nicolaus Copernicus was the first to present to the world a detailed and eventually widely accepted mathematical model supporting the premise that the Earth is moving and the Sun actually stays still, despite the impression from our point of view of a moving Sun.

Planets
Sunsets on other planets appear different because of differences in the distance of the planet from the Sun and non-existent or differing atmospheric compositions.

Mars
On Mars, the setting Sun appears about two-thirds the size it does from Earth, due to the greater distance between Mars and the Sun. The colors are typically hues of blue, but some Martian sunsets last significantly longer and appear far redder than is typical on Earth.
The colors of the Martian sunset differ from those on Earth. Mars has a thin atmosphere, lacking oxygen and nitrogen, so the light scattering is not dominated by a Rayleigh Scattering process. Instead, the air is full of red dust, blown into the atmosphere by high winds, so its sky color is mainly determined by a Mie Scattering process, resulting in more blue hues than an Earth sunset. One study also reported that Martian dust high in the atmosphere can reflect sunlight up to two hours after the Sun has set, casting a diffuse glow across the surface of Mars.

See also
Dawn
Diffuse sky radiation
Earth's shadow, visible at sunset
Golden hour (photography)
Sundown town

References
External links

Full physical explanation in simple terms
The colors of twilight and sunset
The physics of Sunsets - more detailed explanation including the role of clouds
Geolocation service to calculate the time of sunrise and sunset