XML Feed for determining daylight hours
Does anyone know of a feed for determining what time it gets light and dark based on post code or longitude latitude coordinates. We need it for use in a booking system to avoid bookin开发者_如何学Cgs after dark.
Any ideas?
Marvellous
Odd booking system. Anyway, the BBC weather feed gives you sunset and sunrise times. Its in RSS.
You can use EarthTools Sunrise and Sunset Times webservice to get sunrise/sunset times and calculate daylight with them (XML format):
http://www.earthtools.org/sun/latitude/longitude/day/month/timezone/dst
Sunrise and sunset times are calculated using a PHP script using formulae from www.srrb.noaa.gov. There might be errors when using latitudes which are close to the poles.
As @Tomasz wrote another way is to use local computation. For example there is easy to use LuckyCat Labs Sunrise/Sunset Java Library for Java (RubySunrise Gem for Ruby is also available).
There are plenty of resources over the Internet:
- C# Sunrise/Sunset with latitude/longitude - SO
- http://www.weatherimages.org/latlonsun.html
- http://www.ga.gov.au/geodesy/astro/sunrise.jsp
You don't need a web-service, this is a matter of moderately complicated program (earth is more or less just a spinning ball) which you can run locally.
A few years old of a question, but php has built-in functions to get this data.
$reldate=new DateTime();
$reldate->modify('+'.$dayp.' days');
$today['SUNR']=date_sunrise($reldate->format('U'), SUNFUNCS_RET_STRING, 39.36, -74.60, 90.583333, -4);
$today['SUNS']=date_sunset ($reldate->format('U'), SUNFUNCS_RET_STRING, 39.36, -74.60, 90.583333, -4);
精彩评论