Sunrise & Sunset Calculator

JJ Ben-Joseph headshot JJ Ben-Joseph

Overview

This sunrise and sunset calculator estimates the times the Sun’s upper edge crosses an ideal (flat) horizon for a given latitude, longitude, and date. It uses common astronomical approximations (similar in spirit to public NOAA-style methods) and applies a standard correction for atmospheric refraction and the Sun’s apparent radius.

What you’ll get: estimated sunrise time, estimated sunset time, and (optionally, depending on implementation) related values such as daylight length and solar noon. Results are typically displayed in your device/browser time zone unless the calculator offers a time zone selector.

Inputs (and how to enter them)

  • Latitude (φ): degrees north/south of the equator. Valid range: −90 to +90. North is positive; south is negative.
  • Longitude (λ): degrees east/west of Greenwich. Valid range: −180 to +180. East is positive; west is negative (e.g., New York City is about −74°).
  • Date: the calendar date for which you want sun times.

How sunrise/sunset are defined

“Sunrise” and “sunset” are not computed for the Sun’s center exactly at the geometric horizon. Most almanacs define them when the Sun’s upper limb touches the horizon. To approximate this, calculations commonly use a target solar elevation of:

a = −0.833°

This value bundles typical atmospheric refraction near the horizon (~34 arcminutes) and the Sun’s apparent semi-diameter (~16 arcminutes). Real conditions can shift observed times by minutes.

Core formulas (conceptual)

At a high level, sunrise and sunset come from solving when the Sun reaches the chosen elevation angle a at your latitude on the given date. A standard approach uses the Sun’s declination (δ) and the local hour angle (H).

1) Solar declination (δ)

The declination δ is the Sun’s angular position north/south of Earth’s equatorial plane. It changes slowly day to day as Earth orbits the Sun. There are several approximations; many calculators compute δ from the day-of-year or from a Julian-date-based solar model.

2) Hour angle at sunrise/sunset (H)

For a given latitude φ, declination δ, and target elevation a, the sunrise/sunset hour angle satisfies:

cos ( H ) = sin ( a ) sin ( φ ) sin ( δ ) cos ( φ ) cos ( δ )

Once you compute H (in degrees), you can convert it to time because Earth rotates ~15° per hour. Conceptually:

  • Solar noon happens when the Sun crosses the local meridian.
  • Sunrise is approximately solar-noon minus H/15 hours.
  • Sunset is approximately solar-noon plus H/15 hours.

Practical calculators also account for the “equation of time” (the difference between mean time and apparent solar time) and longitude offset from the time zone’s standard meridian.

Interpreting results

  • Sunrise time: when the Sun first becomes visible over an ideal horizon (upper edge), using the −0.833° convention.
  • Sunset time: when the Sun’s upper edge disappears below an ideal horizon.
  • Day length: time between sunrise and sunset. This is a useful derived value for planning outdoor time.

If your results differ from an “official” local source by a few minutes, that can be normal due to differences in refraction assumptions, elevation, horizon obstructions, rounding, and the solar model used.

Worked example

Example: New York City (approx. 40.71° latitude, −74.01° longitude) on 2024-06-21.

  1. Enter Latitude: 40.71
  2. Enter Longitude: −74.01
  3. Select Date: 2024-06-21
  4. Press Calculate

You should see sunrise around the early morning and sunset in the evening (roughly matching the long daylight near the June solstice in the northern hemisphere). Exact minutes can vary by method and time-zone/DST handling.

Method comparison

Feature This calculator Professional astronomy software Simple location lookup
Inputs Latitude, longitude, date Coordinates + elevation + pressure/temperature + more City/location name, date
Horizon model Ideal flat horizon Can model terrain/horizon/elevation Typically assumes defaults
Refraction handling Standard −0.833° convention Configurable / physical refraction models Varies; often undocumented
Output detail Sunrise/sunset (and sometimes day length) Sunrise/sunset + twilight + azimuth + solar noon Usually sunrise/sunset only
Best for Planning, quick estimates anywhere on Earth High-precision needs (aviation, research) Convenience for common places

Assumptions & limitations

  • Standard refraction + solar radius: Uses the common −0.833° sunrise/sunset definition. Real refraction varies with pressure, temperature, and humidity.
  • Sea-level / no elevation adjustment: If you are at higher elevation (mountain, tall building), you can often see the Sun earlier at sunrise and later at sunset than this estimate.
  • Flat, unobstructed horizon: Buildings, hills, and terrain can delay sunrise or hasten sunset relative to the calculation.
  • High latitudes: Near the Arctic/Antarctic circles, there are dates when the Sun does not rise or does not set. In these cases, the hour-angle equation may have no real solution (the calculator should indicate “no sunrise” / “no sunset”).
  • Time zone & DST: If results are shown in your device time zone, traveling users or coordinates outside your time zone may see misleading “local” times. Daylight Saving Time rules can also affect displayed clock time by one hour depending on date and region.
  • Model differences: Different solar algorithms (and rounding) can shift results by a few minutes compared with government almanacs or observatories.

FAQ

Does the calculator include Daylight Saving Time (DST)?

It depends on how the page converts solar time to clock time. If it uses your device/browser time zone, DST is typically applied automatically for your current zone, but that may not match the coordinates you entered if they are in a different region.

Why are my results different from NOAA or a weather app?

Small differences (often a few minutes) can come from different refraction assumptions, rounding, elevation/horizon differences, or the time zone used to display results.

What longitude sign should I use?

Use positive values for east longitudes and negative values for west longitudes (e.g., London ~ −0.13, Tokyo ~ +139.7, New York ~ −74.0).

Can there be no sunrise or no sunset?

Yes. At very high latitudes, some dates have continuous daylight (midnight sun) or continuous night (polar night). The calculator should indicate when sunrise/sunset does not occur on that date.

Is this the same as twilight times?

No. Sunrise/sunset uses the −0.833° convention. Twilight (civil/nautical/astronomical) uses different solar elevation thresholds (e.g., −6°, −12°, −18°) and is not the same as sunrise/sunset.

Embed this calculator

Copy and paste the HTML below to add the Sunrise & Sunset Calculator: Calculate Daily Sun Times by Location to your website.