PHP date_sun_info() Function

What is a Date Sun Info Function?

Explanation

The "date_sun_info()" function returns an array with information about the sunset/sunrise and twilight begin/end details.

Syntax:


array date_sun_info (int $time,float $latitude, float $longitude)

In the above syntax "$time" is the timestamp, logitude, latitude in degrees.

Example :


<?php
$sun = date_sun_info(strtotime( "2006-12-12"), 31.7667, 35.2333);
foreach ($sun as $key => $val) {
echo "$key: " . date("H:i:s", $val) . "n";
}
?>
Result :

sunrise: 05:52:11
sunset: 15:41:21
transit: 10:46:46
civil_twilight_begin: 05:24:08
civil_twilight_end: 16:09:24
nautical_twilight_begin: 04:52:25
nautical_twilight_end: 16:41:06
astronomical_twilight_begin: 04:21:32
astronomical_twilight_end: 17:12:00

In the above example date_sun_info() function will display sunset, sunrise and twilight begin, twilight end details, for the specified time.

Note :

(PHP 5 >= 5.1.2)

PHP Topics


Ask Questions

Ask Question