date_sun_info
(PHP 5 >= 5.1.2, PHP 7, PHP 8)
date_sun_info — 일몰/일출 및 황혼 시작/종료에 대한 정보가 포함된 배열을 반환합니다.
설명
date_sun_info(int $timestamp
, float $latitude
, float $longitude
): array
매개변수
timestamp
- Unix timestamp.
latitude
- Latitude in degrees.
longitude
- Longitude in degrees.
반환 값
성공하면 배열을 반환하고 실패하면 false
을 반환합니다. 어레이의 구조는 다음 목록에 자세히 설명되어 있습니다.
sunrise
- 일출의 타임스탬프(천정각 = 90°35').
sunset
- 일몰의 타임스탬프(천정각 = 90°35').
transit
- 태양이 정점에 있을 때의 타임스탬프입니다. 즉, 가장 높은 지점에 도달했습니다.
civil_twilight_begin
- The start of the civil dawn (zenith angle = 96°). It ends at
sunrise
. civil_twilight_end
- The end of the civil dusk (zenith angle = 96°). It starts at
sunset
. nautical_twilight_begin
- The start of the nautical dawn (zenith angle = 102°). It ends at
civil_twilight_begin
. nautical_twilight_end
- The end of the nautical dusk (zenith angle = 102°). It starts at
civil_twilight_end
. astronomical_twilight_begin
- The start of the astronomical dawn (zenith angle = 108°). It ends at
nautical_twilight_begin
. astronomical_twilight_end
- The end of the astronomical dusk (zenith angle = 108°). It starts at
nautical_twilight_end
.
배열 요소의 값은 UNIX 타임스탬프이며, 태양이 하루 종일 해당 천정 아래에 있으면 false
이고, 하루 종일 해당 천정 위에 태양이 있으면 true
입니다.
Examples
예제 #1 date_sun_info() 예제
<?php
$sun_info = date_sun_info(strtotime("2006-12-12"), 31.7667, 35.2333);
foreach ($sun_info as $key => $val) {
echo "$key: " . date("H:i:s", $val) . "\n";
}
?>
위의 예는 다음을 출력합니다.
sunrise: 05:52:11 sunset: 15:41:21 transit: 10:46:46 civil_twilight_begin: 05:24:08 civil_twilight_end: 16:09:24 nautical_twilight_begin: 04:52:25 nautical_twilight_end: 16:41:06 astronomical_twilight_begin: 04:21:32 astronomical_twilight_end: 17:12:00
예제 #2 Polar night
<?php
var_dump(date_sun_info(strtotime("2017-12-21"), 90, 0));
?>
위의 예는 다음을 출력합니다.
array(9) { ["sunrise"]=> bool(false) ["sunset"]=> bool(false) ["transit"]=> int(1513857490) ["civil_twilight_begin"]=> bool(false) ["civil_twilight_end"]=> bool(false) ["nautical_twilight_begin"]=> bool(false) ["nautical_twilight_end"]=> bool(false) ["astronomical_twilight_begin"]=> bool(false) ["astronomical_twilight_end"]=> bool(false) }
예제 #3 Midnight sun
<?php
var_dump(date_sun_info(strtotime("2017-06-21"), 90, 0));
?>
위의 예는 다음을 출력합니다.
array(9) { ["sunrise"]=> bool(true) ["sunset"]=> bool(true) ["transit"]=> int(1498046510) ["civil_twilight_begin"]=> bool(true) ["civil_twilight_end"]=> bool(true) ["nautical_twilight_begin"]=> bool(true) ["nautical_twilight_end"]=> bool(true) ["astronomical_twilight_begin"]=> bool(true) ["astronomical_twilight_end"]=> bool(true) }
기타
- date_sunrise() - 주어진 날짜와 위치에 대한 일출 시간을 반환합니다.
- date_sunset() - 주어진 날짜와 위치에 대한 일몰 시간을 반환합니다.