Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a formula that will return the number of hours per day given a specific location. I was thinking that can be calculated as a difference of sunrise and sunset, but I see that there are some other ways, like in this topic.

What is the best, fast and correct way to calculate this?

share|cite|improve this question
2 - Do you need analytical solution? I think such function would be very complicated... – Pygmalion May 18 '12 at 16:38
@Pygmalion I need something that I can further program using simple math functions available in PHP. I have the lat/lng and the date as starting points and I need to calculate some monthly averages, while keeping the individual values also on daily basis. – Elzo Valugi May 18 '12 at 17:26
You can find declination formula needed in John's reference here Therefore the solution between Artic and Antartic circle is finalized. I am puzzled about the rest. – Pygmalion May 18 '12 at 17:50 – anna v May 18 '12 at 18:41
up vote 2 down vote accepted

I think that

provide enough information. You put the equation from the second link into the equation from the first link. You get hours by multiplying the positive solution $\omega_0$ by $2 \cdot \frac{24\text{h}}{2\pi}$. If the equation from the first link has no solution ($\tan\phi \cdot \tan\delta>1$ ), this means day is either $24\text{h}$ or $0\text{h}$ long.

As far as I checked equations' output, they seem to be consistent.

share|cite|improve this answer

Number of hours of sunlight on nth day of the year =

12+(Max hrs of sunlight -min hrs of sunlight in the year)/2 * sin[(2π/365)*(n-t) ] where t is that day that has 12 hours of sunlight.

share|cite|improve this answer
Of course this formula is valid between Arctic and Antarctic circle – Pygmalion May 18 '12 at 16:55
I am actually interested in something that will work and above Arctic circle as I am in North Norway and the data is from here. – Elzo Valugi May 18 '12 at 17:24

Thanks to all for the answers. In my context I have all I need through a function called date_sun_info which returns something like this, given latitude and longitude and a date:

[sunrise] => 319016278
[sunset] => 319040766
[transit] => 319028522
[civil_twilight_begin] => 319012129
[civil_twilight_end] => 319044915
[nautical_twilight_begin] => 319007891
[nautical_twilight_end] => 319049153
[astronomical_twilight_begin] => 319003840
[astronomical_twilight_end] => 319053204

I've put this only as a reference for further searches and I'll still select an answer based on the other people contributions. Thanks

share|cite|improve this answer

I have done some number crunching and found an equation for this exact question. For the town I live in the equation is 730-198sin ((2Pit/365)+(Pi/2) For any given location the 730 is the average between the longest and shortest day in minutes. This number may vary just slightly. For the 198sin, the coefficient 198 is the difference between the longest and shortest day in minutes. The variable is t for days from the winter solstice (winter solstice is day 0). The remainder of the equation is just a constant.

share|cite|improve this answer
You should include your reasonings and calculations here to improve your question. – rmhleo Jan 21 at 14:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.