Mostrar lista de opciones

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);
?>
Resultado
$timestamp = 1711719558
$latitude = 48.85
$longitude = 2.35
$array = [
  
'sunrise' => 1711690329,
  
'sunset' => 1711736278,
  
'transit' => 1711713304,
  
'civil_twilight_begin' => 1711688422,
  
'civil_twilight_end' => 1711738186,
  
'nautical_twilight_begin' => 1711686137,
  
'nautical_twilight_end' => 1711740471,
  
'astronomical_twilight_begin' => 1711683731,
  
'astronomical_twilight_end' => 1711742877,
]
$date_sun_info = [
  
'sunrise' => '06:32:09',
  
'sunset' => '19:17:58',
  
'transit' => '12:55:04',
  
'civil_twilight_begin' => '06:00:22',
  
'civil_twilight_end' => '19:49:46',
  
'nautical_twilight_begin' => '05:22:17',
  
'nautical_twilight_end' => '20:27:51',
  
'astronomical_twilight_begin' => '04:42:11',
  
'astronomical_twilight_end' => '21:07:57',
]
Ejemplos
#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)
Ver también
array_map, date, date_default_timezone_set, date_sunrise, date_sunset, pbx_get_city_lat_lng, strtotime