Sunrise Sunset Calculator

Last updated: 2026-09-09

Sunrise Sunset Calculator — Calculate sunrise and sunset times.
Inputs
°
day
Result
Enter values and press Calculate
Common Examples — Click to Fill
LatitudeDay of year
Light 2086
Moderate 30129
Strong 40172
Severe 60258
Extreme 80344

TL;DR: To calculate sunrise and sunset times, input your latitude, longitude, date, and timezone offset into the calculator; the core formula determines the solar hour angle at sunrise and sunset, where cos(H₀) = -tan(latitude) × tan(solar declination), and then converts that angle into a UTC-based local time using the equation of time.

What Is the Sunrise Sunset Calculator?

The Sunrise Sunset Calculator is a specialised astronomical tool that determines the exact local clock times when the upper limb of the Sun appears on the horizon (sunrise) and when it disappears below the horizon (sunset). Unlike generic weather apps that provide rough estimates, this calculator uses precise celestial geometry to account for your exact position on Earth and the date you specify. It produces results to the minute, which is critical for professionals and enthusiasts who need reliable daylight data.

This tool serves a wide range of users. Photographers use sunrise and sunset times to plan golden hour shoots. Farmers and agricultural managers schedule irrigation and harvesting around daylight availability. Architects and urban planners evaluate natural lighting for building designs. Outdoor event organisers time ceremonies, races, or festivals. Additionally, religious practitioners in traditions that require prayer times tied to solar events, and hikers or climbers who need to know when daylight will end in remote areas, all rely on this type of precise calculation.

What sets this calculator apart is its reliance on your specific geographic coordinates rather than a generic city-wide approximation. Two locations within the same city can experience sunrise and sunset times that differ by several minutes due to longitude differences and local terrain. This level of accuracy is only possible with input-based calculations using the standard solar geometry equations described in this article.

How to Use the Calculator

Using the Sunrise Sunset Calculator is straightforward if you have the correct inputs ready. Follow these steps to get accurate results.

  1. Enter the date (YYYY-MM-DD): Input the specific date for which you want the solar times. The format is year-month-day (for example, 2026-06-21 for the summer solstice). The calculator will automatically determine the solar declination for this specific day of the year.
  2. Enter your latitude (decimal degrees): This is your north-south position on Earth. For the northern hemisphere, use a positive value (e.g., 40.4168 for Madrid). For the southern hemisphere, use a negative value (e.g., -33.8688 for Sydney). The maximum valid range is -90 to +90, corresponding to the geographic poles.
  3. Enter your longitude (decimal degrees): This is your east-west position on Earth. For locations east of the Prime Meridian (Greenwich), use a positive value (e.g., -3.7038 for Madrid). For the western hemisphere, use a negative value (e.g., 151.2093 for Sydney is actually east, so that is positive; for New York, -74.0060). The valid range is -180 to +180.
  4. Enter your UTC offset (hours): This is the difference between your local standard time and Coordinated Universal Time (UTC). For example, Madrid in June uses CEST (Central European Summer Time), which is UTC+2, so you would enter 2. For New York in winter (EST), you would enter -5. Ensure you account for daylight saving time manually, as the calculator does not automatically apply DST rules.
  5. Click 'Calculate': After entering the four values, press the calculate button. The tool will process your inputs, apply the solar position equations, and display the sunrise and sunset times in your local timezone.

Formula and Calculation Method

The calculation method used here is based on the standard solar geometry algorithm developed by the National Oceanic and Atmospheric Administration (NOAA). It computes the solar declination and equation of time for the given date, then derives the hour angle at sunrise and sunset. The process is broken down into four logical steps.

Step 1: Fractional Year (γ)

First, convert the date of the year into a fractional year in radians. For a given day number (N, where January 1 is day 1), use this formula:

γ = (2π / 365) × (N - 1 + (hour - 12) / 24)

For this calculator, we assume the calculation for solar noon (hour = 12) to get a stable value. This γ parameter captures the Earth's orbital position.

Step 2: Equation of Time and Solar Declination

Next, compute two key solar parameters. The equation of time (eqtime) corrects for the Earth's elliptical orbit and axial tilt, in minutes:

eqtime = 229.18 × (0.000075 + 0.001868 × cos(γ) - 0.032077 × sin(γ) - 0.014615 × cos(2γ) - 0.040849 × sin(2γ))

The solar declination (decl) is the angle of the Sun relative to Earth's equatorial plane, in radians:

decl = 0.006918 - 0.399912 × cos(γ) + 0.070257 × sin(γ) - 0.006758 × cos(2γ) + 0.000907 × sin(2γ) - 0.002697 × cos(3γ) + 0.00148 × sin(3γ)

Step 3: Hour Angle at Sunrise/Sunset

The hour angle (H₀) is the angular distance the Sun must travel from solar noon to reach the horizon. The standard formula is:

cos(H₀) = -tan(latitude) × tan(decl)

Convert latitude to radians before application. If cos(H₀) has an absolute value greater than 1, it means the Sun does not rise or set that day (polar day or night). The result H₀ is in degrees; convert to minutes: H₀_minutes = H₀ × 4 minutes per degree.

Step 4: Convert to Local Time

Combine the equation of time and hour angle to find solar noon first:

Solar Noon (minutes from UTC) = 720 + (−longitude_degrees × 4 minutes/degree) − eqtime

Then calculate sunrise and sunset in minutes from UTC:

  • Sunrise (UTC minutes) = Solar Noon − H₀_minutes
  • Sunset (UTC minutes) = Solar Noon + H₀_minutes

Finally, add the UTC offset (in minutes) to get local standard time. Divide by 60 to get hours and minutes.

Worked Example: Madrid on 2026-06-21

Let us apply this to Madrid, Spain on the 2026 summer solstice. Inputs: latitude = 40.4168° N (positive), longitude = −3.7038° W (negative, west of Greenwich), UTC offset = +2 (CEST). June 21 is day 172 of 2026.

Step 1: γ = (2π/365) × (172 − 1 + 0) = (0.017214) × 171 = 2.9437 radians.

Step 2: Computing eqtime: You should get approximately −1.82 minutes. Computing decl: You should get approximately 0.4066 radians (23.44 degrees), which is the maximum solar declination on the solstice.

Step 3: Convert latitude to radians: 40.4168° × (π/180) = 0.7056 radians. Then cos(H₀) = −tan(0.7056) × tan(0.4066) = −(0.8511) × (0.4348) = −0.3700. Therefore, H₀ = arccos(−0.3700) = 111.72 degrees. H₀ in minutes: 111.72 × 4 = 446.88 minutes.

Step 4: Solar Noon (UTC minutes) = 720 + (−(−3.7038) × 4) − (−1.82) = 720 + (14.815) + 1.82 = 736.64 minutes UTC. Add UTC offset: 736.64 + 120 (2 hours) = 856.64 minutes local. Convert: 856.64 / 60 = 14.277 hours = 14:16 local solar noon.

Sunrise (UTC) = 736.64 − 446.88 = 289.76 minutes. Local = 289.76 + 120 = 409.76 minutes = 6:50 AM. Sunset (UTC) = 736.64 + 446.88 = 1183.52 minutes. Local = 1183.52 + 120 = 1303.52 minutes = 21:43 (9:43 PM).

The actual astronomical values for Madrid on that date are approximately 6:47 AM and 9:44 PM, so our result is within a few minutes due to minor rounding in this example.

Practical Examples

Here are three realistic scenarios showing how the calculator is used in different contexts.

ExampleDateLatitude (°)Longitude (°)UTC Offset (h)Result
Photographer in Sydney2026-01-15-33.8688151.2093+11Sunrise 5:58 AM, Sunset 8:05 PM
Construction manager in Toronto2026-03-20 (equinox)43.6532-79.3832-4 (EDT)Sunrise 7:16 AM, Sunset 7:29 PM
Polar researcher in Tromsø, Norway2026-11-2569.649218.9553+1Sunrise 11:02 AM, Sunset 1:32 PM (only 2.5 hours of daylight)

In the Sydney example, the high positive longitude and negative latitude combine with the southern hemisphere summer to produce early sunrises and late sunsets. In the Toronto example, the March equinox shows almost exactly 12 hours of daylight, demonstrating the equality of day and night. The Tromsø example shows the extreme shortening of daylight near the Arctic Circle in late autumn, where the Sun barely grazes the horizon. These scenarios illustrate how dramatically latitude changes the solar times.

Tips for Accurate Results

To get reliable times from the calculator, you must avoid the most common pitfalls. The following tips will help you obtain precise data every time.

  • Double-check sign conventions for longitude: Users frequently mix up the sign for western longitudes. In this calculator, longitudes west of Greenwich (Americas, UK, Portugal) must be negative. Longitudes east (Europe, Asia, Australia, Africa) must be positive. Using a positive value for New York or a negative value for Madrid will produce results that are off by your longitude's time correction, potentially by over an hour.
  • Verify the UTC offset includes daylight saving time: The calculator expects the total UTC offset for your local clock time on that exact date. In summer, Madrid uses UTC+2 (CEST), but in winter it uses UTC+1 (CET). If you enter only the standard offset without DST, your result will be off by one hour. Always check the current offset for your specific date.
  • Do not round intermediate results: As shown in the worked example, rounding the equation of time or the hour angle early in the process can shift your final times by several minutes. Keep at least six decimal places during your manual calculations. The calculator does this automatically, but if you manually verify, avoid rounding until the final step.
  • Verify the validity range: The calculator is designed for dates between 1900 and 2099 and latitudes between ±65 degrees for optimal accuracy. Outside this range, the simplified model used here loses precision. For polar regions beyond ±65°, results may be inaccurate, especially near the polar day or polar night boundary where cos(H₀) approaches ±1.
  • Understand the output is for a flat horizon: The calculated times assume a perfectly flat horizon at sea level. If standing on a mountain or in a valley, your local horizon may be higher or lower, significantly shifting actual visible sunrise or sunset. The times from the calculator are the geometric sunrise and sunset for your coordinates, not for your specific terrain.

Frequently Asked Questions

1. Why is my sunset time different by several minutes from a weather app or website?

This discrepancy is extremely common and typically has three causes: differences in coordinates, timezone handling, and horizon definition. General weather apps often use the centroid of your city or a major local airport, not your exact address. If you live in a suburban area with your home longitude differing from the city centre by even 0.1 degree, that alone shifts solar noon by 0.4 minutes (24 seconds). Second, many apps automatically apply daylight saving time based on your current date, but if you are calculating a date in a different season, you may be using the wrong offset. Finally, most weather apps assume the same flat-horizon approximation this calculator uses, but some add corrections for atmospheric refraction and the Sun's semi-diameter. The US Naval Observatory, for example, adds about 50 minutes of arc for refraction plus 16 arcminutes for the Sun's radius, which effectively makes sunrise appear about 2-3 minutes earlier and sunset 2-3 minutes later than the geometric times. The most reliable way to match your results is to input your exact GPS coordinates and confirm the UTC offset for your specific date.

2. Can this calculator determine if there is polar day or polar night at my location?

Yes, implicitly. The calculation of cos(H₀) = −tan(latitude) × tan(decl) reveals this directly. If the absolute value of the right-hand side exceeds 1, the arccosine function has no real solution. In practice, this occurs when the Sun's declination is such that it never sets (polar day) or never rises (polar night) at your latitude. The calculator will display an error or a '24h daylight' or '24h darkness' message instead of a time. For example, at Tromsø, Norway (69.6492° N), around June 20, the condition gives cos(H₀) = −tan(69.6492°) × tan(23.44°) = −2.724 × 0.4348 = −1.184, which is less than −1, so no sunrise or sunset occurs. This condition is precisely why the tip section advises not using this calculator for latitudes above 65°; the simple model has a hard cut-off, whereas in reality the Sun grazes the horizon for days near the boundary. To get accurate times in this zone, you would need a more complex nautical almanac calculation.

3. Why does the sunrise time change so quickly around the equinoxes?

The rate of change in sunrise time is maximal near both the March and September equinoxes because the solar declination changes most rapidly then. Declination changes at about 0.4 degrees per day near the equinox, compared to nearly zero change near the solstices. This large daily change in declination directly alters the hour angle H₀ via the cos(H₀) formula. Essentially, the Sun is moving quickly northward (or southward) each day, shifting the sunrise time by several minutes daily. Around the equinoxes, you may see sunrise shift by 2-3 minutes per day, while around the summer solstice you might only see a 15-second change per day. This is why the 'golden hour' for photographers shifts so dramatically in spring and autumn. In contrast, the winter solstice marks the 'slowest' sunrise time change, which is why the earliest sunset occurs about two weeks before the solstice, not on the solstice itself—the mornings are still getting later while the evenings begin to get later, creating an asymmetry in the calendar.