PHP date_sun_info() Function
Example
Return information about sunset/sunrise and twilight begin/end on 1st January, 2013, for latitude 31.7667, longitude 35.2333:
<?php
$sun_info=date_sun_info(strtotime("2013-01-01"),31.7667,35.2333);
foreach ($sun_info as $key=>$val)
{
echo "$key: " . date("H:i:s",$val) . "<br>";
}
?>
Try it Yourself »
Definition and Usage
The date_sun_info() function returns an array containing information about sunset/sunrise and twilight begin/end, for a specified day and location.
Tip: Look at the date_sunrise() function to return the sunrise time for a specified day and location.
Tip: Look at the date_sunset() function to return the sunset time for a specified day and location.
Syntax
date_sun_info(timestamp, latitude, longitude)
Parameter Values
Parameter | Description |
---|---|
timestamp | Required. Specifies a timestamp |
latitude | Required. Specifies the latitude in degrees |
longitude | Required. Specifies the longitude in degrees |
Technical Details
Return Value: | Returns an array on success. FALSE on failure |
---|---|
PHP Version: | 5.1.2+ |
❮ PHP Date/Time Reference