ive created a php script on my server that will dish up the sunrise/sunset times for the nominated lat, long and GMT offset. there is an option to get civillian (type=1), nautical (type=2) and astronomical (type=3) times as well (script plucked straight from php manual and manipulated a bit).
so if you hit:
http://www.22solutions.com.au/sunrise/sunrise.php?lat=-37.55&long=143.85&offset=11&type=0
you’ll get the sunrise/sunset times for ballarat. change the type to get the different times.
enter your own lat, long and offset and it will return the data. lat is positive for north and long is positive for east. i tried with Los Angeles data and it was all good.
http://www.22solutions.com.au/sunrise/sunrise.php?lat=34.052&long=-118.2428&offset=-8&type=0
i have started on building some opto code to get this into some variables, but for some reason softpac keeps returning -443 on the status…hmmm…
heres the php script in case anyone else wants it:
<?php
$lat = isset($_GET['lat'])?$_GET['lat']:''; //either get nav or clear the string
$long = isset($_GET['long'])?$_GET['long']:''; //either get nav or clear the string
$offset = isset($_GET['offset'])?$_GET['offset']:''; //either get nav or clear the string
$type = isset($_GET['type'])?$_GET['type']:'0'; //either get nav or clear the string
if ($lat == '' or $long == '' or $offset == ''){echo "error";}
else{
switch ($type)
{
case "1":
$zenith=96;
echo "<br><p>Civilian Twilight start- ".date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);
echo "<br>Civilian Twilight end- ".date_sunset(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);
break;
case "2":
$zenith=102;
echo "<br><p>Nautical Twilight start- ".date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);
echo "<br>Nautical Twilight end- ".date_sunset(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);
break;
case "3":
$zenith=108;
echo "<br><p>Astronomical Twilight start- ".date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);
echo "<br>Astronomical Twilight end- ".date_sunset(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);
break;
default:
$zenith=90+50/60;
echo "<br><p>Sunrise- ".date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);
echo "<br>Sunset- ".date_sunset(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);
break;
}
}
?>
might be a start for someone out there who is keen to get this going as well.
Nick