Sunrise Sunset Calculator

This sunrise and sunset calculator estimates how long the day lasts and when the Sun crosses the horizon, from just your latitude and the day of the year. It uses the standard solar-position relations published by the US National Oceanic and Atmospheric Administration: it first finds the Sun's declination for the chosen day, then solves the sunrise equation to get the hour angle of sunrise, which fixes both the length of daylight and the local solar times of sunrise and sunset. Enter a latitude in decimal degrees, positive north of the equator and negative south of it, and a day number from 1 for January 1 to 365 for December 31. The result is given in local apparent solar time, the time the Sun itself keeps, which differs from clock time by your longitude offset, time zone and the equation of time. Use it to see how summer days stretch toward the poles, plan photography around the golden hour, or check daylight for a trip. Every figure is computed deterministically from the declination and hour-angle formulas shown in full below, with a worked example that reconciles exactly to the calculator so you can follow each step yourself.

Solar declination and the sunrise equation set the day length: at latitude 40 degrees on day 172 (around June 21) the declination is 23.45 degrees, giving 14.85 hours of daylight, with solar sunrise at 04:35 and sunset at 19:25.

Source: US National Oceanic and Atmospheric Administration (NOAA). As at 25 June 2026.

North positive, south negative
172 is around 21 June
Solar declination--
Solar sunrise / sunset--
Daylight length--

Sunrise and sunset formula

declination = 23.45 x sin( 360 / 365 x (284 + N) )
cos(H) = -tan(lat) x tan(declination)
daylight hours = 2 x H / 15
sunrise = 12 - H / 15, sunset = 12 + H / 15 (local solar time)
N = day of year, H = hour angle in degrees

The declination is the Sun's angle north or south of the equator for the day. The hour angle H is how far the Sun sits from local noon when it crosses the horizon; doubling it and dividing by 15 degrees per hour gives the length of daylight.

Worked example

Find the daylight length at latitude 40 on day 172 of the year, near the June solstice.

  1. declination = 23.45 x sin(360 / 365 x (284 + 172)) = 23.45 deg
  2. cos(H) = -tan(40 deg) x tan(23.45 deg) = -0.839100 x 0.433620 = -0.363845
  3. H = arccos(-0.363845) = 111.34 deg
  4. daylight = 2 x 111.34 / 15 = 14.85 hours
  5. sunrise = 12 - 111.34 / 15 = 04:35; sunset = 12 + 111.34 / 15 = 19:25 (solar time)

Daylight lasts 14.85 hours with solar sunrise at 04:35 and sunset at 19:25. These are the calculator's default inputs, so the result above matches the widget exactly.

Daylight length by latitude on the June solstice

On day 172 the Sun's declination is 23.45 degrees. Daylight grows quickly with latitude toward the summer pole.

Latitude (deg)Daylight (hours)
012.00
2013.21
4014.85
6018.53
66.524.00

Method and solar-position reference: US National Oceanic and Atmospheric Administration (NOAA).

Sunrise Sunset Calculator: frequently asked questions

What time zone are the results in?

The sunrise and sunset times are given in local apparent solar time, the time kept by the Sun itself, where noon is the moment the Sun crosses your meridian. To convert to clock time you adjust for your longitude within your time zone, the time zone offset and the equation of time. This calculator reports solar time so the result depends only on latitude and date, not on which time zone line you happen to sit behind.

Why does daylight depend on latitude?

The length of daylight is set by how high the Sun climbs, which depends on your latitude and the Sun's declination. Near the equator day and night stay close to 12 hours all year. Toward the poles the tilt of the Earth swings the Sun far above or below the horizon, so summer days lengthen toward 24 hours of continuous daylight above the Arctic and Antarctic circles.

What is solar declination?

Solar declination is the angle of the Sun north or south of the celestial equator on a given day. It ranges from about +23.45 degrees at the June solstice to -23.45 degrees at the December solstice, passing through zero at the equinoxes. This calculator uses the standard Cooper approximation, declination = 23.45 x sin(360/365 x (284 + N)), which is accurate to within about half a degree.

How accurate are the times?

The model treats the Sun as a point and ignores atmospheric refraction and the Sun's angular size, both of which make the real Sun appear to rise a little earlier and set a little later. It is good for planning and reference to within a few minutes at mid-latitudes. For precise civil sunrise tables, consult the official NOAA solar calculator, which applies the full refraction and equation-of-time corrections.

What day number do I enter?

Enter the day of the year, counting January 1 as day 1 and December 31 as day 365 (366 in a leap year). Day 172 is around June 21, the northern summer solstice; day 355 is around December 21; days 80 and 266 are near the spring and autumn equinoxes.

Official sources

Reviewed by the CalculatorHub team, edited by James Graham, 25 June 2026. See our methodology. This is general information, not financial, tax, legal or investment advice.