ForHosting KIT · Science

Daylight hours calculator

At the equator every day has 12 hours of daylight, while toward the poles a summer day stretches to 24 and a winter day shrinks to 0. Enter the day of the year and your latitude to get the hours of sunlight. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Day
172
Latitude
0
You get
Result
12
Declination deg
23.45
Daylight hours
12
Hour angle deg
90

A daylight hours calculator answers a seasonal question that architects, growers, sailors, and astronomy students keep asking: how many hours of sunlight fall on a given latitude on a given day of the year. At the equator the model yields twelve hours every day; toward the poles it stretches toward twenty-four hours around the local summer solstice and collapses toward zero around the local winter solstice.

Solar declination, the hour angle, and how daylight hours are formed

Daylight duration is the time the geometric centre of the Sun spends above the true horizon. That interval is twice the solar hour angle at sunrise, and the hour angle follows from spherical astronomy once two angles are known: the observer's latitude φ and the Sun's declination δ. Declination is the latitude of the subsolar point; it swings between roughly plus and minus the obliquity of the ecliptic over a tropical year.

Full reductions use the true longitude of the Sun, the equation of centre, and nutation, but engineering and classroom practice often need only a smooth seasonal curve. This calculator uses the Cooper cosine seasonal model with a fixed obliquity of 23.45 degrees and a peak at day 172, which approximates 21 June in a non-leap calendar: δ equals 23.45 degrees times the cosine of two π over 365 times day minus 172.

The geometric sunrise identity is then cos ω₀ equals minus tan φ times tan δ, and daylight hours D equal 24 over π times arccos of that cosine, equivalently two-fifteenths of the hour angle in degrees. When the absolute value of tan φ tan δ is at least one, arccos is undefined on the real line: the Sun never sets (midnight sun, 24 hours) or never rises (polar night, 0 hours).

The model ignores atmospheric refraction, the finite solar disk, and the equation of time, so civil sunrise tables that use a depression of 0.833 degrees will differ by a few minutes; the identity here is the closed-form geometric day length taught with the declination model.

Who needs day length, and what happens at the poles

Greenhouses, vineyard managers, and outdoor-event planners use a daylight hours calculator when they already know the calendar day and the site latitude and need the seasonal photoperiod without standing up an ephemeris stack. Architects and energy modelers sketch winter daylight at 40 or 50 degrees north to size glazing and estimate lighting loads before they graduate to a typical-meteorological-year file. Sailors and high-latitude field teams check whether a summer day at 70 degrees north is still a normal sunrise-sunset pair or has already entered midnight sun.

Classrooms and exam-prep generators need a deterministic oracle for the geometric identity so a grader can mark both the twelve-hour equator case and the rejection of a latitude outside minus 90 to plus 90. Prefer this capability when you have a day of year and a latitude and only need hours of geometric daylight.

Seasonal photoperiod for growers and events

Greenhouse, vineyard, and outdoor-event planners convert a calendar day and a site latitude into hours of daylight without installing an ephemeris library.

Architecture and daylighting sketches

Early energy models need winter versus summer day length at a design latitude to size glazing and lighting before a typical-meteorological-year file is available.

How does the daylight hours calculator compute duration from day and latitude?

It approximates solar declination with δ=23.45·cos(2π/365·(N−172)), then evaluates D=(24/π)·arccos(−tan(φ)·tan(δ)). Send integer day (1–366) and lat in degrees.

Why is daylight twelve hours at the equator on every day?

At lat 0, tan(φ) is zero, so the sunrise hour angle is 90 degrees and D is exactly 12 hours in the geometric model, independent of declination.

What does day 172 mean, and how do I find my day number?

Days are counted from 1 January, which is day 1, so day 172 falls near 21 June, the northern summer solstice. Day 366 is accepted too, so the last day of a leap year has its own number.

What does the calculator show near the poles?

When the Sun never sets, it returns 24 hours of midnight sun; when the Sun never rises, it returns 0 hours of polar night. That lets a team at 70 degrees north see whether a summer day still has a sunset.

Why does my local sunrise table differ by a few minutes?

Published tables usually allow for the bending of light in the air and for the size of the solar disk. This calculator measures how long the centre of the Sun stays above a flat horizon, so the two can differ by a few minutes.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/phys/daylight

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/phys/daylight \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"day":172,"lat":40}'
{
  "day": 172,
  "lat": 40
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "phys.daylight",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

This endpoint takes the ordinal day of year and the observer's geodetic latitude, approximates the Sun's declination with the standard cosine seasonal model, and returns the geometric duration of daylight in hours. Latitude outside the closed interval from minus ninety to plus ninety degrees is rejected with invalid_input rather than a wrapped or imaginary result.

Solar declination, the hour angle, and how daylight hours are formed

Identical inputs always produce identical JSON because the path is pure floating-point arithmetic.

Input contract, response shape, and the latitude range error

Day 1 is 1 January, day 172 sits near the northern summer solstice, and 366 is allowed so a leap day can be addressed without inventing a 367th tropical-year sample. Missing day, a non-integer day, day 0, and day 367 are likewise rejected. Example: day 172 and lat 0 yield twelve hours exactly, because tan of the equator is zero and arccos of zero is a right angle. POST a JSON body with two required finite numbers: day, the integer day of year from 1 through 366 inclusive (aliases day_of_year, doy, n, and N), and lat, the observer latitude in decimal degrees from minus 90 to plus 90 inclusive (aliases latitude, phi, and latitude_deg). Each field may arrive as a JSON number or as a numeric string; booleans, empty strings, and non-finite values fail with invalid_input naming the field. If lat is outside the closed interval from minus 90 to plus 90 degrees the task fails with invalid_input and is not billed—the tangent of latitude is not defined beyond the poles, and wrapping 91 degrees to a co-latitude would silently compute daylight for the wrong place. On success the body echoes day and lat, then reports declination_deg from the cosine model, daylight_hours as the primary duration in hours, result as an alias of daylight_hours, hour_angle_deg as the sunrise hour angle in degrees (0 in polar night, 180 under midnight sun), regime as normal, midnight_sun, or polar_night, plus formula and method strings so a client can log which approximation produced the hour count. Pricing is a flat $0.002 per successful request with unit item; failed validation does not consume prepaid balance.

Who uses a daylight duration API, polar cases, and what this page is not

Send day 172 with a northern latitude to see the local maximum; send day 355 for the local minimum; send lat 90 with a summer day to read 24 hours and regime midnight_sun, or a winter day to read 0 hours and polar_night. This page targets people searching for a daylight hours calculator, daylight duration from date and latitude, or photoperiod from a solar declination model. It is not a US daylight-saving start date, not a civil-twilight or sunrise-clock tool with time zone and longitude, not a solar-altitude-at-noon solver, and not a converter of solar mass or panel wattage.

Classroom and polar-regime checks

Students and graders verify the twelve-hour equator identity, midnight sun and polar night clamps, and the invalid_input error when latitude falls outside −90 to 90 degrees.

What happens if latitude is outside −90 to 90 degrees?

The task fails with invalid_input naming lat. Latitude beyond the poles is not a geographic position for this model, and the request is not billed.

Does the calculator handle midnight sun and polar night?

Yes. When |tan(φ) tan(δ)| ≥ 1 there is no real sunrise hour angle: daylight_hours is 24 with regime midnight_sun, or 0 with regime polar_night.

What does the daylight hours calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →