Sunrise & Sunset Times Widget

Add sunrise and sunset times to your website for your town or any coordinates. Visitors see day length, solar noon and civil, nautical and astronomical twilight, with polar day and night handled properly.

Time & Date Calculator Runs in your browser Free · no ads

Customize your widget

Theme
Auto follows the visitor's light/dark setting.
Style
Attribution on your page
Optional and entirely your choice. The exact line is shown in the code below; it links to the tool with rel="nofollow".
More options
Starting values
Leave blank to use the widget's defaults. Visitors can still change every value.

Live preview

Exactly what your visitors will see

Embed code

<iframe src="https://a2z.tools/embed/w/sunrise-sunset" title="Sunrise &amp; Sunset Times by A2Z Tools" width="100%" height="740" style="border:0;width:100%" loading="lazy" allow="clipboard-write"></iframe>

A plain iframe. Works everywhere, including site builders that strip scripts. Adjust height if your content needs more room.

Works with

How it works

The widget uses the A2Z astronomy engine, which implements the NOAA solar calculator equations (after Meeus): the Sun's declination and the equation of time give solar noon, and the hour angle at which the Sun's centre is 0.833 degrees below the horizon gives sunrise and sunset (0.833 degrees allows for atmospheric refraction and the Sun's radius). Twilights use 6, 12 and 18 degrees below the horizon. Times are shown in the IANA time zone you choose, with daylight saving applied, and an event that falls after midnight is labelled "next day". Near the poles, where the Sun may not rise or set at all, the widget says so instead of showing a time.

Calculation method

  • Solar noon (UTC minutes) = 720 - 4 x longitude - equation of time
  • cos(H) = cos(zenith) / (cos(lat) cos(decl)) - tan(lat) tan(decl); sunrise/sunset = solar noon -/+ 4H minutes
  • Zenith 90.833 deg for sunrise/sunset; 96, 102 and 108 deg for civil, nautical and astronomical twilight
  • |cos H| > 1: the Sun stays above (midnight sun) or below (polar night) that angle all day

Limitations

  • Assumes a flat sea-level horizon and standard refraction; elevation, mountains and buildings are not modelled.
  • Golden hour and blue hour are not listed as separate times.
  • Dates outside 1800-2200 are refused.
  • The time zone is not guessed from the coordinates - choose it, or preset v_zone.

Where publishers use it

  • Photography and travel blogs listing golden-hour and twilight times
  • Local news and weather sites for a town or region
  • Religious and community sites that time events to sunrise or sunset
  • Outdoor, hiking and sailing clubs planning daylight hours

Questions

How accurate are the times?

Within a minute or two of the US Naval Observatory for most places. Hills, tall buildings, air temperature and pressure can change what you actually see by a few minutes.

How do I set my location?

Enter latitude and longitude in decimal degrees (north and east positive), and choose the time zone. Publishers can preset v_lat, v_lon, v_zone and a v_place name.

What is civil twilight?

The time when the Sun is less than 6 degrees below the horizon: usually bright enough to be outdoors without lights. Nautical twilight ends at 12 degrees and astronomical at 18 degrees.

Why does it say the Sun is up all day?

Inside the Arctic or Antarctic circle in summer the Sun does not set (midnight sun), and in winter it does not rise (polar night). The widget reports that instead of an invented time.

Sources

  1. NOAA Solar Calculator: calculation details - NOAA Global Monitoring Laboratory . Equations (after Meeus) for declination, equation of time and the 0.833 degree sunrise/sunset altitude
  2. Complete Sun and Moon Data for One Day - US Naval Observatory, Astronomical Applications Dept. . Reference sunrise, sunset and civil twilight times the widget is tested against

Cite or recommend this tool

If you reference this tool in an article, course or documentation, these formats are ready to copy. They are optional - nothing is added to your site unless you paste it.

A2Z Tools Sunrise & Sunset Times
https://a2z.tools/sunrise-sunset-calculator
  • Moon Phase

    Time & Date Tool

    Today's Moon phase drawn to scale, with illumination, age and the next full and new moon.

  • Prayer Times

    Time & Date Calculator

    Fajr, Sunrise, Dhuhr, Asr, Maghrib and Isha for any place, with the major calculation methods.

  • Time Zone Converter

    Time & Date Converter

    Convert a date and time between any two time zones, with daylight-saving gaps and overlaps explained.

  • Digital Clock

    Time & Date Clock & time

    A large live digital clock for any time zone, with seconds, date and a 12/24-hour switch.

  • Countdown Timer

    Time & Date Clock & time

    Live days, hours, minutes and seconds to a date you set, with an "event has started" message.

  • Age Calculator

    Time & Date Calculator

    Exact age in years, months and days, totals in months, weeks and days, and the next birthday.

Preview