|
Calculating time of sunrise / sunset for location with date_sunrise / date_sunset |
|
Built-in function calculates the time of sunset and sunrise with
latitude, longitude, zenith, and GMT offset. Added in PHP 5. (Credit:
http://www.php.net/manual/en/function.date-sunset.php under ODL1.0)
-
<?php
-
-
/* calculate the sunrise time for Lisbon, Portugal
-
Latitude: 38.4 North
-
Longitude: 9 West
-
Zenith ~= 90
-
offset: +1 GMT
-
*/
-
-
echo date("D M d Y"). ', sunrise time : ' .date_sunrise (time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1);
-
-
?>
-
-
outputs: Mon Dec 20 2004, sunrise time : 08:54
-
-
<?php
-
-
/* calculate the sunset time for Lisbon, Portugal
-
Latitude: 38.4 North
-
Longitude: 9 West
-
Zenith ~= 90
-
offset: +1 GMT
-
*/
-
-
echo date("D M d Y"). ', sunset time : ' .date_sunset (time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1);
-
-
?>
-
-
outputs: Mon Dec 20 2004, sunset time : 18:13
|