Reputation: 2175
How can I calculate the sunrise and sunset in the area that the user is visiting a site in with javascript / jquery ?
I tried looking at this question, but didn't get much help from the answers.
I just want to be able to print sunrise: sunrise time is here and sunset: sunset time here.
Upvotes: 0
Views: 2203
Reputation:
Another solution is to query an existing service. Here is a similar question: link
Upvotes: 0
Reputation: 73
A quick solution is to use XMLHTTPRequest to a script that returns the result from PHP's date_sunrise/date_sunset methods:
http://php.net/manual/en/function.date-sunrise.php
Otherwise, you'll have to maintain a database of the required information and reproduce that algorithm. However, this looks like it might do it out of the box:
http://www.github.com/mourner/suncalc
Upvotes: 1