I have a time, and a given latitude in degrees. Is there any method of calculating the time of sunrise and sunset in Javascript with this information?
Sunrise/Sunset Calculations where the positive number corresponds to sunrise, negative to sunset. Then the UTC time of sunrise (or sunset) in minutes is: sunrise = 720 – 4*(longitude + ha) – eqtime where longitude and hour angle are in degrees and the equation of time is in minutes.
How do I calculate daylight hours? Multiply 2 by the sunrise or sunset angle. Divide the product with 15 to get the daylight hours.
How are the times of sunset and sunrise determined? A. Sunset and sunrise have exactly the same definition: the time when the apparent uppermost ray of the Sun is on the astronomical horizon. If it is the first ray, it is sunrise and if it is the last ray, it is sunset.
SunCalc seems to do what you want
SunCalc is a tiny BSD-licensed JavaScript library for calculating sun position, sunlight phases (times for sunrise, sunset, dusk, etc.), moon position and lunar phase for the given location and time
https://github.com/mourner/suncalc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With