PHP date_sun_info()Functions

PHP Date/TimePHP Date/Time Reference Manual

Examples

Returns information about sunrise/sunset and dusk start/dusk end for January 1, 2013, 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>";
}
?>

Run Example »

Definition and Usage

The date_sun_info() function returns an array containing information about sunrise/sunset and dusk start/dusk end for the specified date and location.

Tip:See alsodate_sunrise()function, returns the sunrise time for the specified date and location.

Tip:See alsodate_sunset()function, returns the sunset time for the specified date and location.

Syntax

date_sun_info(timestamp,latitude,longitude);

Parameter Description
timestamp Required. Specifies the timestamp.
latitude Required. Specifies the latitude.
longitude Required. Specifies the longitude.

Technical Details

Return value: Returns an array on success, or FALSE on failure.
PHP Version: 5.1.2+


PHP Date/TimePHP Date/Time Reference Manual Other Extensions