Display the drop-down list

date_sun_info()

« date_default_timezone_set | date_sunrise »
<?php
// enter a $time or a $timestamp
// select a $city or enter the $latitude and $longitude

// gets a timestamp from a date
date_default_timezone_set(
    
? // string $timezone
);
$timestamp strtotime(
    
 // string $time
);

// gets the latitude and longitude of a city
list($latitude$longitude) = pbx_get_city_lat_lng(
    
? // string $city
);

$array date_sun_info (
    
// int $timestamp
    
// float $latitude
    
  // float $longitude
);

// shows the times in a readable format
$date_sun_info array_map(
    function(
$timestamp) { return date("H:i:s"$timestamp); },
    
$array);
?>
Result
$timestamp = 1500670221
$latitude = 48.850000000000001
$longitude = 2.3500000000000001
$array = [
  
'sunrise' => 1500610251,
  
'sunset' => 1500666196,
  
'transit' => 1500638223,
  
'civil_twilight_begin' => 1500607904,
  
'civil_twilight_end' => 1500668543,
  
'nautical_twilight_begin' => 1500604753,
  
'nautical_twilight_end' => 1500671694,
  
'astronomical_twilight_begin' => 1500600427,
  
'astronomical_twilight_end' => 1500676019,
]
$date_sun_info = [
  
'sunrise' => '06:10:51',
  
'sunset' => '21:43:16',
  
'transit' => '13:57:03',
  
'civil_twilight_begin' => '05:31:44',
  
'civil_twilight_end' => '22:22:23',
  
'nautical_twilight_begin' => '04:39:13',
  
'nautical_twilight_end' => '23:14:54',
  
'astronomical_twilight_begin' => '03:27:07',
  
'astronomical_twilight_end' => '00:26:59',
]
Examples
#1 date_sun_info  (/* $timezone = "Europe/Paris" */
 /* $time = "now" */
 /* $city = "Paris" */
 
$timestamp,
 
$latitude,
 
$longitude)
#2 date_sun_info  (/* $timezone = "UTC" */
 /* $time = "2006-12-12" */
 
$timestamp,
 
31.7667,
 
35.2333)
#3 date_sun_info  (/* $timezone = "UTC" */
 
962409600,
 
50,
 
50)
See also
array_map, date, date_default_timezone_set, date_sunrise, date_sunset, pbx_get_city_lat_lng, strtotime