# Sunrise and Sunset Calculator

> Computes sunrise, sunset, solar noon, day length and civil twilight for any date, latitude and longitude with the NOAA Solar Calculator algorithm (Meeus-based solar position, equation of time, zenith 90.833° for refraction and the solar disc), reported in an IANA time zone.

- Calculator id: `sunrise-sunset` · Category: Time & Geography (`time`) · Tool name: `calculate_sunrise_sunset`
- Canonical page: https://tttkmbb.com/time/sunrise-sunset · This document: https://tttkmbb.com/time/sunrise-sunset.md · JSON definition: https://tttkmbb.com/time/sunrise-sunset.json

## Purpose

Computes sunrise, sunset, solar noon, day length and civil twilight for any date, latitude and longitude with the NOAA Solar Calculator algorithm (Meeus-based solar position, equation of time, zenith 90.833° for refraction and the solar disc), reported in an IANA time zone.

**Use when:** You need sunrise/sunset or daylight hours for a place and date, e.g. for photography, outdoor planning, solar energy or prayer-time style scheduling.

**Do not use when:** You need minute-exact times for legal purposes, times at elevations far above sea level or with obstructed horizons, or moonrise/moonset (not covered); use moon-phase for the lunar phase.

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `date` | date |  | optional, default "today" | Calendar date in time_zone (YYYY-MM-DD); defaults to the current UTC date. |
| `latitude` | number | ° | required | Latitude in decimal degrees (north positive, south negative). (min -90, max 90) |
| `longitude` | number | ° | required | Longitude in decimal degrees (east positive, west negative). (min -180, max 180) |
| `time_zone` | string |  | optional, default "UTC" | IANA time zone for the reported times, normally the zone of the location (e.g. Australia/Adelaide). Defaults to UTC. |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `sunrise` | string |  | Local time (HH:MM) the upper limb of the Sun appears; absent during polar day/night. |
| `sunset` | string |  | Local time (HH:MM) the upper limb disappears; absent during polar day/night. |
| `solar_noon` | string |  | Local time the Sun crosses the meridian (highest point). |
| `day_length` | string |  | Time between sunrise and sunset as hours and minutes. |
| `day_length_hours` | number | h | Day length in decimal hours (0 in polar night, 24 in polar day). |
| `civil_twilight_begin` | string |  | Local time the Sun's centre is 6° below the horizon before sunrise (zenith 96°). |
| `civil_twilight_end` | string |  | Local time the Sun's centre reaches 6° below the horizon after sunset. |
| `sunrise_utc` | string |  | Sunrise instant in UTC (ISO 8601). |
| `sunset_utc` | string |  | Sunset instant in UTC (ISO 8601). |
| `solar_declination_degrees` | number | ° | Declination of the Sun at solar noon. |
| `equation_of_time_minutes` | number | min | Apparent solar time minus mean solar time at solar noon. |
| `utc_offset` | string |  | Offset of time_zone on that date (±HH:MM). |
| `sun_status` | string |  | 'Sun rises and sets', 'Polar day: Sun above the horizon all day' or 'Polar night: Sun below the horizon all day'. |

## Formula

`cos(HA) = cos(90.833°) / (cos φ · cos δ) − tan φ · tan δ; sunrise_UTC = 720 − 4 · (longitude + HA) − EoT minutes; sunset_UTC = 720 − 4 · (longitude − HA) − EoT; solar_noon_UTC = 720 − 4 · longitude − EoT; civil twilight uses zenith 96°`

Implements NOAA's spreadsheet/JavaScript algorithm: solar declination δ and equation of time EoT from the Julian century (Meeus), one refinement pass at the estimated event time, refraction and solar radius folded into the 90.833° zenith. Accuracy is about ±1 minute for latitudes up to ±72° (±10 minutes nearer the poles); results are the events that fall on the given calendar date in time_zone.

## Data Sources

- NOAA Global Monitoring Laboratory – Solar Calculator: calculation details — https://gml.noaa.gov/grad/solcalc/calcdetails.html (government, retrieved 2026-09-24)
- NOAA – General Solar Position Calculations (solareqns.pdf) — https://gml.noaa.gov/grad/solcalc/solareqns.PDF (government, retrieved 2026-09-24)
- Sunrise equation (Wikipedia) — https://en.wikipedia.org/wiki/Sunrise_equation (reference, retrieved 2026-09-24)

Data freshness: `daily` (max_age_seconds 86400). Depends on the current date unless the date is supplied.

## API

- `GET https://tttkmbb.com/api/v1/calculate/sunrise-sunset?latitude=…&longitude=…`
- `POST https://tttkmbb.com/api/v1/calculate/sunrise-sunset` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/sunrise-sunset · OpenAPI operationId `calculate_sunrise_sunset` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "sunrise-sunset", "inputs": {…}}`

## Example

- Adelaide (−34.9285, 138.6007) on 2026-09-23: inputs `{"date":"2026-09-23","latitude":-34.9285,"longitude":138.6007,"time_zone":"Australia/Adelaide"}` → `{"sunrise":"06:04","sunset":"18:12","solar_noon":"12:08","civil_twilight_begin":"05:39","civil_twilight_end":"18:38","sunrise_utc":"2026-09-22T20:34:00Z","utc_offset":"+09:30","sun_status":"Sun rises and sets"}`
- London (51.5074, −0.1278) on the June solstice 2026: inputs `{"date":"2026-06-21","latitude":51.5074,"longitude":-0.1278,"time_zone":"Europe/London"}` → `{"sunrise":"04:43","sunset":"21:22","solar_noon":"13:02","day_length":"16 h 38 min","day_length_hours":16.63,"civil_twilight_begin":"03:55","civil_twilight_end":"22:09","solar_declination_degrees":23.44}`

```
GET https://tttkmbb.com/api/v1/calculate/sunrise-sunset?date=2026-09-23&latitude=-34.9285&longitude=138.6007&time_zone=Australia%2FAdelaide
```

## Limitations

You need minute-exact times for legal purposes, times at elevations far above sea level or with obstructed horizons, or moonrise/moonset (not covered); use moon-phase for the lunar phase. Implements NOAA's spreadsheet/JavaScript algorithm: solar declination δ and equation of time EoT from the Julian century (Meeus), one refinement pass at the estimated event time, refraction and solar radius folded into the 90.833° zenith. Accuracy is about ±1 minute for latitudes up to ±72° (±10 minutes nearer the poles); results are the events that fall on the given calendar date in time_zone. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why do published times sometimes differ by a minute?**

Almanacs round differently and use slightly different refraction models; NOAA's method is accurate to about one minute at mid-latitudes. Local terrain, elevation and atmospheric conditions can shift the observed event by several minutes.

**What happens inside the polar circles?**

When the Sun stays above (polar day) or below (polar night) the horizon all day, sunrise and sunset are omitted, sun_status explains why and day_length_hours is 24 or 0. Civil twilight is still reported when it occurs.

## Related

- [Moon Phase Calculator](https://tttkmbb.com/time/moon-phase.md) — Lunar phase and illumination for the same date.
- [Time Zone Converter](https://tttkmbb.com/time/time-zone-converter.md) — Express the sunrise time in another zone.
- [Julian Date Calculator](https://tttkmbb.com/time/julian-date.md) — Julian Date used internally by the solar position formulas.
