显示下拉菜单

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);
?>
结果
$array = [
  
'sunrise' => 962411728,
  
'sunset' => 962470348,
  
'transit' => 962441038,
  
'civil_twilight_begin' => 962409089,
  
'civil_twilight_end' => 962472987,
  
'nautical_twilight_begin' => 962405247,
  
'nautical_twilight_end' => 962476829,
  
'astronomical_twilight_begin' => true,
  
'astronomical_twilight_end' => true,
]
$date_sun_info = [
  
'sunrise' => '00:35:28',
  
'sunset' => '16:52:28',
  
'transit' => '08:43:58',
  
'civil_twilight_begin' => '23:51:29',
  
'civil_twilight_end' => '17:36:27',
  
'nautical_twilight_begin' => '22:47:27',
  
'nautical_twilight_end' => '18:40:29',
  
'astronomical_twilight_begin' => '00:00:01',
  
'astronomical_twilight_end' => '00:00:01',
]
示例
#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)
另请参阅
array_map, date, date_default_timezone_set, date_sunrise, date_sunset, pbx_get_city_lat_lng, strtotime