PHP date_sun_info() Function
Definition
The date_sun_info() function returns an array containing information about sunset/sunrise and twilight begin/end, for a specified day and location.
date_sunrise() function returns the sunrise time for a specified day and location. date_sunset() function returns the sunset time for a specified day and location.
Syntax
PHP date_sun_info() Function has the following syntax.
date_sun_info(timestamp,latitude,longitude);
Parameter
Parameter | Is Required | Description |
---|---|---|
timestamp | Required. | timestamp |
latitude | Required. | Latitude in degrees |
longitude | Required. | Longitude in degrees |
Return
PHP date_sun_info() Function returns an array on success. FALSE on failure.
Example
Return information about sunset/sunrise and twilight begin/end on 1st January, 2013, for latitude 21.0000, longitude 30.0000:
<?php/* ww w . jav a 2 s.c o m*/
$sun_info=date_sun_info(strtotime("2013-01-01"),21.0000,30.0000);
foreach ($sun_info as $key=>$val){
echo "$key: " . date("H:i:s",$val) . "<br>";
}
?>
The code above generates the following result.