Take the 2-minute tour ×
Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free, no registration required.

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|improve this question
2  
    
en.wikipedia.org/wiki/Day_length - 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 en.wikipedia.org/wiki/Declination. Therefore the solution between Artic and Antartic circle is finalized. I am puzzled about the rest. –  Pygmalion May 18 '12 at 17:50
    
jgiesen.de/daylight –  anna v May 18 '12 at 18:41
add comment

3 Answers 3

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|improve this answer
add comment

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|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
add comment

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|improve this answer
add comment

Your Answer

 
discard

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.