Fun with PHP
A neat little bit of code to display sunrise and sunset (the functions are built into PHP but I’m guessing many people don’t realize).
$lat = 47.133031;
$lon = -122.274538;
$zenith=90+50/60;
$offset=0;
$location = "Puyallup, WA"
$sunrise=date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, $lat, $lon, $zenith, $offset);
$sunset=date_sunset((time() + (12 * 60 * 60)), SUNFUNCS_RET_TIMESTAMP, $lat, $lon, $zenith, $offset);
$message = "<ul>";
if (date("U", $sunrise) < date("U", time()))
{
$message .= "The sun rose today at ";
}
else
{
$message .= "The sun will rise today at ";
}
$message .= date("g:i a", $sunrise);
if (date("U", $sunset) < date("U", time()))
{
$message .= " and the sun set today at ";
}
else
{
$message .= " and the sun will set today at ";
}
$message .= date("g:i a", $sunset);
$message .= "</ul>";
echo($message);Andrew Flanagan on February 20th 2007 in Geekiness