PHP date_sun_info() Function
In this chapter you will learn:
- Definition for PHP date_sun_info() Function
- Syntax for PHP date_sun_info() Function
- Parameter for PHP date_sun_info() Function
- Return for PHP date_sun_info() Function
- Example
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//from ja v a2 s .c om
$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.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP date_sunrise() Function
- Syntax for PHP date_sunrise() Function
- Parameter for PHP date_sunrise() Function
- Return value from PHP date_sunrise() Function
- Example - Return the sunrise time for Lisbon, Portugal today
Home » PHP Tutorial » PHP Date Functions