How do I calculate the hours of daylight on an arbitrary planet for a given day at a given latitude?

I want to be able to graph the change in daylight hours across the year for a given latitude, to get an idea of what kind of cycle in available daylight people at that latitude would live through and adapt to. I'm assuming "daylight hours" is the time between the two periods the top of the star is tangent with the horizon in a solar day (sunrise/sunset), assuming the horizon is flat.

The problem is I have no background in mathematics or astrophysics, and all the answers I've found so far seem to assume I know a bunch of terms and formulas off-hand. I'm asking about an arbitrary planet because I can't even find a clear answer on what information about my planet I even need to consider, thus I've no idea what information I should be giving.

...and it reads: Here's how I'd go at it:

1) For a given orbit day (elapsed planetary days since perihelion, for simplicity) calculate the true anomaly.

2) From the true anomaly, calculate the orbital angular velocity.

3) From the orbital angular velocity and the rotation angular velocity, calculate the mean angular velocity of the sun across the sky.

4) From the latitude, axial tilt and [true anomaly-solstice anomaly], calculate the angular length of sun's path in the sky at the required latitude.

5) From 3) and 4), derive the day length.

Now thru google and wikipedia I've learned enough (I think) to make it past step 2. However, "rotation angular velocity" is not a a specific term I can find any info on. I ASSUME it's the angular velocity for the spin of the planet, but I'm not really sure... and then we have "calculate the mean angular velocity of the sun across the sky", which sounds like something that translates to a fairly long equation that clearly isn't given here, nor anywhere else I've searched. Am I supposed to just average the 2 other angular velocities in this step? That doesn't seem right.

Steps 4 and 5 utterly defeat me. If I knew what equations to plug those values into, I don't think I would need to ask this question at all. "solstice anomaly" is another term that seems to exist nowhere else but in this post. Another problem is that these angular values can be expressed in radians or degrees, and I have no idea how those wildly different values should factor into the equation, which I should use, how it would change the final answer...

In essence, I just wanna know what numbers I need to know about my planet and what formulas to plug them into to get a basic idea of what the damn sun is doing. I'm aware that doing this at multiple latitudes for every day will be hilariously tedious, but as long as I know the process, I can at least get started.

I'll also have to calculate the movement of multiple celestial objects eventually, as the movement of particular planets/stars/constellations tends to have a notable effect on what traits/gods people ascribe to them, so I might as well start off relatively easy...

• Welcome to Worldbuilding! This is a good first question (my opinion!). In future, be careful of supplement info like your closing paragraph. If you veer off to tangents, it can often lead to less on-topic answers. Always ask just one question per post... you can always post follow-up questions later in a new post. Here’s hoping your first question draws some useful answers for you! – SRM Feb 8 at 13:47
• The answer to this question is highly dependent on how accurate you want to be. Do you want a simple model that gives a rough approximation, or a complex model that gives a detailed approximation? – Lawton Feb 8 at 16:02

A graphical method

Sometimes a graphical method may be easier to understand and remember.

One year is the time required for the planet to complete one full orbit around its primary. You decide how long a year is; it could be shorter than an Earth year, it could be longer; but if the star is similar to our Sun, and the planet is supposed to be habitable for life as we know it, it cannot be all that much shorter or all that much longer.

A day can be reckoned in two ways.

• The simplest way is the time required for the planet to complete a full rotation around its axis; this is called a sidereal day, because it is the time between two culminations of any given star. ("Sidera" means stars in Latin.)

You choose the length of the sidereal day. It can shorter than an Earth day, it can be longer. There is no relationship between the length of the year and the length of the sidereal day.

• The more complicated, but more useful way is to reckon the time between two culminations of the planet's sun, that is, the time from one noon to the next; this is called a solar day, and it is a bit longer than a sidereal day, and can be calculated as the duration of one sidereal day plus a fraction of the sidereal day equal to the ratio between the sideral day and the year.

• For Earth, a sidereal day is 23 hours 56 minutes, and an average solar day is 24 hours. (The current definition of the second was chosen very carefully, so that the mean solar day computed for 1 January 1900 is almost exactly 24 hours.)

(The solar day is longer than the sidereal day because by the time the planet has completed one rotation around the axis it has also advanced a little bit on its orbit, and it must rotate a little bit more to bring the sun in the same position.)

(Of course, if the planet rotates in the opposite direction of its revolution around the primary, the solar day will be shorter than the sidereal day, with the same amount. Most planets don't do this -- they rotate around the axis and revolve around the primary in the same direction.)

As the planet revolves around its primary there are four important points on the orbit:

1. At one point, the axis of rotation appears to be tilted towards the primary at a maximum, equal to the obliquity. This is the northern solstice, which is the summer solstice for people in the northern hemisphere. At the northern solstice, at all places on the planet north of the northern polar circle, that is, the northern parallel of 90° less the axial tilt, the sun doesn't set; and at all places on the planet south of the southern polar circle, that is, the southern parallel of 90° less the axial tilt, the sun doesn't rise.

2. Then comes a point where the axis of rotation is perpendicular to the radius of the orbit; this is an equinox. At equinoxes, days and nights are equal at all latitudes.

3. Then comes a point where the axis of rotation appears to be tilted away from primary at a maximum, equal to the obliquity. This is the southern solstice, which is the winter solstice for people in the northern hemisphere. At the southern solstice, at all places on the planet north of the northern polar circle, that is, the northern parallel of 90° less the axial tilt, the sun doesn't rise; and at all places on the planet south of the southern polar circle, that is, the southern parallel of 90° less the axial tilt, the sun doesn't set.

4. Finally, a second point where the axis of rotation is perpendicular to the radius of the orbit; this is an equinox. At equinoxes, days and nights are equal at all latitudes. Then the cycle repeats.

Assumming that the planet has a circular or almost circular orbit around its primary, the four points (two solstices and two equinoxes) are almost equally spaced within the year.

What you want to do is compute the duration of daylight for a given latitude at the northern solstice; then you can estimate the duration of daylight for that latitude at any time in the year.

How to compute the duration of day and night at summer or winter solstice for a given latitude using a graphical method. Own work, available on Flickr under the Creative Commons Attribution 2.0 Generic license.

1. Draw the planet tilted towards the Sun.

2. Draw the equator; notice that on the equator the days and nights are of equal length at all times.

3. Draw the polar circles as lines parallel to the equator starting from the topmost and bottommost points on the planet.

4. Draw the terminator, that is, the line separating day from night. Note the position of the terminator with respect to the lines representing the polar circles.

5. With a protractor, identify your parallel of interest. In the picture, the parallel of interest is at 30°.

6. Now measure how much of that parallel is in the illuminated part of the planet, and how much is in the shadow.

• ”but if the star is similar to our Sun, it cannot be all that much shorter or all that much longer.” Add “if the planet is to be habitable.” – SRM Feb 8 at 16:03
• @SRM: Oh, yes. Added. – AlexP Feb 8 at 16:04
• @AlexP: I assume you'd calculate the day length for your Parallel of Interest at some other point of the year by linear interpolation, as you'd know the min and max day length? – Kyyshak Feb 8 at 16:42
• @Kyyshak: Yes, true. Won't be exact, but it won't be wildly off -- good enough for government work, as they say. – AlexP Feb 8 at 17:19
• It might be worth noting that the length of a year is a function of the mass of the star and the distance of the planet from it. For a more massive star than our sun, a planet will have a year equal to an Earth year at a distance further from the star than Earth is from the sun. For a less massive star, a closer planet will have a year equal to an Earth year. – Scott Feb 8 at 20:53

TL;DR: you need to compute solar declination given your axial tilt, current true anomaly and the true anomaly of the winter solstice. You can feed that and your latitude into the sunrise equation.

Here's a complete worked example though, mostly for my own edification but others might find it helpul or useful.

(and for future readers, the date it was written was the date used to compute various numbers, and was 2020-02-08)

1) For a given orbit day (elapsed planetary days since perihelion, for simplicity) calculate the true anomaly.

Earth's perihelion in 2020 was on the 5th of January, so we're on day 34 of our current orbit. If we say the year length is 365 days and perihelion was precisely at midnight, that makes the current Mean Anomaly 33.5° (something like wolfram alpha will give you a more accurate value, but this'll do for an example).

If Earth had a perfectly circular orbit, the true anomaly would be exactly the same as the mean anomaly. Alas, real life is irrational and unhelpful, and so we do not have a nice tractable circular orbit.

We can compute the True Anomaly via this nice simple equation:

$$\nu = M + \left(2e - \frac{1}{4} e^3\right) \sin M + \frac{5}{4} e^2 \sin 2M + \frac{13}{12} e^3 \sin 3M + \cdots$$

where $$e$$ is the eccentricity of the orbit, which for Earth is ~0.0167, and $$M$$ is the mean anomaly we computed above. Using just these first three terms of the series expansion, we get a true anomaly $$\nu$$ of ~35.63° (and if you wanted more terms, you can have a read of this). Again, a slightly more reputable source than "some person on the internet" will give you a better value, but we're still close enough to see that this simple(ish) example isn't totally wrong.

2) From the true anomaly, calculate the orbital angular velocity.

The orbital velocity of a body changes as it procedes around its orbit... it will be fastest at perihelion, and slowest at aphelion. It is the rate of change of the true anomaly.

For a perfectly circular orbit, it would be simple: about .986° per day, or ~1.1416x10-5 degrees per second.

As before, ellipses ruin everything. You get the the specific relative angular momentum of an orbit where the orbiting body masses much less than the orbited body (as is the case with Earth and the Sun, for example) via this equation:

$$h = \sqrt{GM_sa(1-e^2)}$$

where $$M_s$$ is the mass of the Sun and $$a$$ is the semi-major axis of the planet and $$e$$ is still its orbital eccentricity. Courtesy of this handy answer on physics.SE, you can see that angular velocity $$\omega$$, the rate of change of true anomaly, can be obtained from $$h = \omega r^2$$.

You can get $$r$$ from $$\nu$$ like this:

$$r = \frac{a(1-e^2)}{1 + e \cos(\nu)}$$

So, today's value of $$r$$ is approximately 1.4755x1011m, giving us a current angular velocity of about 1.1724x10-5 degrees per second. As expected, this is a little faster than the circular equivalent, because we're closer to Earth's perihelion than the aphelion and so our orbital speed is a little higher than average.

3) From the orbital angular velocity and the rotation angular velocity, calculate the mean angular velocity of the sun across the sky.

In a circular orbit, if the rotational angular velocity were equal to the orbital angular velocty the world would be tidally locked and the sun would never appear to move. That would make the question a little too easy to answer, though.

The rotational period of the earth (the sidereal day) is a little shorter than the average 24 hour day (the solar day), which is the length of time between the sun reaching its zenith point in successive cycles. There's a handy answer on this very site for computing the solar day length: How to calculate the solar day from sidereal day and sidereal orbital period?

This of course gives you an average solar day length, which isn't quite right as the day length changes slightly due to orbital and rotational inconveniences. I'm going to skip handling the equation of time for now, and cheat by assuming an average 24 day which gives us the mean angular velocity of ~0.0042°/s. I might revisit this later, but don't hold your breath.

3) From the latitude, axial tilt and [true anomaly-solstice anomaly], calculate the angular length of sun's path in the sky at the required latitude.

The solstice anomaly mentioned here is presumably the true anomaly of the planet when it was last at a solstice, that being the point at which a pole is closest to (or further from) the sun. Again, we live on an inconvenient planet where the solstices do not coincide with the apsides (though for various reasons the gap between them changes over time in multi-millenia cycles which I shall ignore entirely. They've coincided in the past, will in the future, and could coincide for your fictional worlds, too). The last winter solstice was roughly at day 350 of last year, and you can compute its true anomaly using the method in step (1), giving $$\nu_w$$ of approximately 343.98°.

Solar declination declination is the angle between the sun's current zenith, and its zenith during the equinoxes, and you can compute it from your planet's axial tilt and the length of time since the last solstice:

$$\delta_\odot = \theta_a \cdot \cos(\nu - \nu_w)$$

where $$\theta_a$$ is the Earth's axial tilt, about -23.44°. Today's declination is therefore approximately -14.55°.

My latitude $$\Phi$$ is about 52° north. You can use the sunrise equation to find the hour angle of sunrise and sunset:

$$\pm \cos \omega_0 = -\tan \Phi \tan \delta_\odot$$

Where sunrise has the positive hour angle and sunset has the negative. The day length is then the sunrise angle minus the sunset angle... in this case about 141 degrees.

(This does assume that the Sun is a point source of light instead of a disc, and atmospheric refraction of light from an over-the-horizon sun is also ignored. You can use a more generalised equation which has an additional term to take these things into account)

Note that when $$\Phi$$ becomes large enough you will find that sunrise and sunset times become no longer defined. This is a sign that the latitude you're looking at is in a period of 24 hour night or day, where it will remain until $$\delta_\odot$$ has moved a bit closer to zero. 75.4N is roughly the limit for a sunrise at the moment, which is why places like Svalbard don't manage a proper daytime right now.

If $$\delta_\odot$$ is zero, then the day has the same length regardless of latitude. This happens on the equinoxes. If axial tilt is zero then on every day of the year the day length will be the same regardless of latitude (though one day might have a slightly different length than the next, depending on your planet's orbital eccentricity).

5) From 3) and 4), derive the day length.

Divide the day length angle from (4) by the angular velocity in (3). In my case, this ands up being approximately 33890 seconds, or a bit over 9 hours and 24 minutes. This is within a few minutes of the actual day length according to timeanddate.com, which is a nice result.

Easy as that!

Note: Handling the difference between civil twilight, nautical twilight, astronomical twilight and night will be left as an exercise for the reader. The additional complexity is minimal ;-)

• I get a solstice anomaly of 343.68, not 343.98. I'm not sufficiently confident in my math to make the edit for you, but any chance you made a typo? – Kofthefens Feb 9 at 20:20
• @Kofthefens I've not been very thorough with the quality of my numbers. Even in the first paragraph in section (1) I admit to using a year length of 365 days ;-) I wouldn't worry about whether your numbers match mine; I'm reasonably happy that the formulae and methods are correct, though (and those bits at least have references). – Starfish Prime Feb 9 at 20:51
• Here's an implementation of these formulas in javascript for anyone who wants to use this answer but doesn't want to go through the math by hand: github.com/KMarshland/hours-of-daylight/blob/master/…. I'll slowly be going through and removing the simplifying assumptions. – Kofthefens Feb 9 at 20:55
• @Kofthefens good stuff. I was intending to do something similar myself; its nice that I can take the lazy option! – Starfish Prime Feb 9 at 20:56

Here is a mostly "simple" formula. It is from an article in Ecological Modeling, volume 80 (1995) pp. 87-95, called "A Model Comparison for Daylength as a Function of Latitude and Day of the Year."

D = daylength

L = latitude

J = day of the year

P = asin[.39795 * cos(.2163108 + 2 * atan{.9671396 * tan[.00860(J - 186)]})]

XX = sin(0.8333 * pi / 180) + sin(L * pi / 180) * sin(P)

YY = cos(L * pi / 180) * cos(P)

D = 24 - (24 / pi) * acos(XX / YY)

The latitude should be entered in degrees.

The model error is less than one minute within 40 degrees of the equator, and less than seven minutes within 60 degrees and usually within two minutes for these latitudes. It is not 100% accurate because the Earth bulges in the center.

EDIT: This reference website will walk you through more math than you might like on this challenge. It explains why the formulas are more complex than given. It also gives examples that extend it to other orbiting bodies. http://www.analemma.com/Pages/framesPage.html

• Whilst the answer is valid for Earth, it isn't obviously that useful for an arbitrary planet (as requested by the OP) because it has magic numbers instead of sensible parameters like orbital semimajor axis, eccentricity, period, planetary rotational period and axial tilt. – Starfish Prime Feb 8 at 14:53
• It’s a great answer if we could get info for where the magic constants came from. Does the citation source include that info? – SRM Feb 8 at 16:02
• Those constants are calculations that address the Earth bias challenges. For example, if the Earth were a perfect sphere, and the sun was shining on it perfectly centered on the equator, the formula is solving for the arc from where the sun rises to where it sets. When you move north or south, the sun doesn't shine exactly perpendicular, so there is an angle with that latitude that the sun is off from being directly perpendicular. This and other oddities are in the magic numbers. I only have the reference and the final formula, so I don't know if it has the magic number detail. – user72081 Feb 8 at 16:09
• @castlewrks Makes sense. Thanks for replying... this answer may serve people working on Earth easier than the general solution. – SRM Feb 8 at 17:20
• See the EDIT link... it gives more detail including applying the math to other planetary bodies. Too complex to post here. It is a great site explaining the complex math involved. – user72081 Feb 8 at 17:24

$$h=\frac{2\cdot\left|\cos^{-1}\left(-\tan\left(-a\left(\cos\left(\frac{360d}{y}\right)\right)\right)\right)\right|}{15}$$

 h = hours of daylight l = latitude (in degrees) a = axial tilt of the planet (in degrees) d = number of days (local days, not Earth days) since the planet's winter solstice in its Northern Hemisphere y = number of days (local days, not Earth days) in a year on the planet 

This formula calculates the length of day in solar decimal Earth hours (not including astronomical refraction (which causes twilight), solar disc diameter, or elevation of the observer) for planets (not including moons) with day lengths shorter than their year lengths that are not tidally locked. However, the influence of the above three factors is very minimal.

Astronomical refraction cannot be calculated unless you know the exact atmospheric composition of the observer. Solar disc diameter requires knowledge of the diameter of the planet's star and the distance of the planet from the star. The length of day on moons is a lot more difficult to calculate because they require calculation of the moon's orbit around its planet. Tidally locked worlds have the same amount of daylight throughout the year except for a few seasonal changes caused by axial tilt.

Note: This answer will give you the number of hours as a decimal. For example, 2 hours and 12 minutes will come out as 2.2. To convert this number into hours, minutes, and seconds; go here: https://unitconverter.net/decimal-to-time-calculator

This answer is adapted from the Sunrise equation1 and the Declination equation2.

• This also does not calculate for true anomaly, but the margin of error is very small. – galactic_analyzer yesterday

Alex P's answer says in part:

One year is the time required for the planet to complete one full orbit around its primary. You decide how long a year is; it could be shorter than an Earth year, it could be longer; but if the star is similar to our Sun, and the planet is supposed to be habitable for life as we know it, it cannot be all that much shorter or all that much longer.

That is correct in stating that the length of a habitable planet's year should not be too much longer than an Earth year.

Stars that are much brighter than the Sun would have inner and outer edges of their habitable zones much farther out than the inner and outer edges of the Sun's habitable zone. So planets in the habitable zones of extremely bright stars could have years hundreds or thousands of Earth years long.

But stars much more massive and much brighter than the Sun would use up their nuclear fuel so fast that it would not last long enough for planet in their habitable zones to become habitable for humans, which would take billions of years of planetary evolution. So I think that planets with multi celled lifeforms, or habitable for humans, should only have years a few times as long as Earth years, maybe five or ten Earth years long at most.

But on the other hand, it may be possible for habitable planets to orbit stars much dimmer than the Sun very closely and to have years much shorter than Earth years.

In Wikipedia's List of Potentially Habitable Exoplanets, exoplanets which orbit within the habitable zones of their planets, the one with the shortest day is TRAPPIST--1 d, which has a year 4.05 Earth days long.

The same is true in The Habitable Exoplanets Catalog, which also lists Teegarden's Star b as having a year 4.9 Earth days long.

So there are two known exoplanets in the habitable zones of their stars which have years less than 0.013 Earth years long. And there are three others listed with years less than 0.02 Earth years long.

One problem with the habitability of planets with such short years would be that tidal effects on planets that close to their stars would cause the planets to quickly (in astronomical and geological time scales) become tidally locked to their planets. So one side of the planet would always face the Sun and become very hot and one side of the planet would be in eternal darkness and get very cold. Such a planet's water and atmosphere might quickly freeze on the dark side and never melt.

However, some calculations indicate that a planet with enough water and atmosphere might circulate heat from the light side to the dark side and equalize temperatures enough to avoid freezing out the water and air.

So if a tidally locked planet in the habitable zone of a dim star can still be habitable, the minimum year length for a habitable planet could be as little as 4 Earth days.

If a tidally locked planet can never be habitable, the minimum year length of a habitable planet would be many times longer, probable several Earth months long.

And another way to have habitable worlds very close to a dim star would be to have them be giant moons of a giant planet orbiting close to the dim star. The moons of a giant planet would become tidally locked to the planet, and not to the star, and so they would have days equal to their periods of rotation around the giant planet.

If the orbital period, and thus the day, of a hypothetical habitable exomoon was in the range of the Galilean moons of Jupiter or of Titan, it would between about 1.5 and 17 Earth days long, and so the moon might avoid too drastic heating and cooling during its daily cycle.

The orbital period of the planet around its star would have to be at least nine times the length of the orbital period of the moon around its planet, so that the year of a habitable exomoon of a giant planet in the habitable On zone of its star should be at least 13.5 to 153 Earth days long.

So depending on the correctness of various speculations and calculations, the minimum possible year length of a habitable exoplanet might be:

1) Several Earth months.

2) 13.5 Earth days.

3) 4.00 Earth days.

I have been trying to implement Starfish Prime;s algorithm, above, in C++. I'm convinced he knows his subject, but I'm a programmer, not a physicist. So here are some questions (and complaints):

You go out of your way to compute w, r and h. They never get used. I feel like I'm missing something here.

You talk about days since winter solstice and days since LAST solstice. I think you always meant last winter solstice (implying shortest day), but then I don't think the negation before tan*tan is correct.

Units! No one is going to implement this on paper, and software likes radians. Knowing which units were intended for the sun's mass, gravity etc (if they matter) would save some hair-pulling.

Clarity appreciated! (and to make this an "answer", I'll post code once I'm sure it's right.)

New contributor
Scott M is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.