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 = 1695579594
$latitude = 48.85
$longitude = 2.35
$array = [
  
'sunrise' => 1695534018,
  
'sunset' => 1695577488,
  
'transit' => 1695555753,
  
'civil_twilight_begin' => 1695532136,
  
'civil_twilight_end' => 1695579370,
  
'nautical_twilight_begin' => 1695529916,
  
'nautical_twilight_end' => 1695581590,
  
'astronomical_twilight_begin' => 1695527627,
  
'astronomical_twilight_end' => 1695583879,
]
$date_sun_info = [
  
'sunrise' => '07:40:18',
  
'sunset' => '19:44:48',
  
'transit' => '13:42:33',
  
'civil_twilight_begin' => '07:08:56',
  
'civil_twilight_end' => '20:16:10',
  
'nautical_twilight_begin' => '06:31:56',
  
'nautical_twilight_end' => '20:53:10',
  
'astronomical_twilight_begin' => '05:53:47',
  
'astronomical_twilight_end' => '21:31:19',
]
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