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

ParameterIs RequiredDescription
timestampRequired.timestamp
latitudeRequired.Latitude in degrees
longitudeRequired.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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions