显示文本框

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);
?>
结果
$timestamp = 1713613365
$latitude = 48.85
$longitude = 2.35
$array = [
  
'sunrise' => 1713588476,
  
'sunset' => 1713639043,
  
'transit' => 1713613759,
  
'civil_twilight_begin' => 1713586440,
  
'civil_twilight_end' => 1713641079,
  
'nautical_twilight_begin' => 1713583909,
  
'nautical_twilight_end' => 1713643609,
  
'astronomical_twilight_begin' => 1713581073,
  
'astronomical_twilight_end' => 1713646445,
]
$date_sun_info = [
  
'sunrise' => '06:47:56',
  
'sunset' => '20:50:43',
  
'transit' => '13:49:19',
  
'civil_twilight_begin' => '06:14:00',
  
'civil_twilight_end' => '21:24:39',
  
'nautical_twilight_begin' => '05:31:49',
  
'nautical_twilight_end' => '22:06:49',
  
'astronomical_twilight_begin' => '04:44:33',
  
'astronomical_twilight_end' => '22:54:05',
]
示例
#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