date_sunset
(PHP 5, PHP 7, PHP 8)
date_sunset — 주어진 날짜 및 위치에 대한 일몰 시간을 반환합니다.
경고 이 함수는 PHP 8.1.0부터 더 이상 사용되지 않습니다. 이 함수에 의존하는 것은 매우 권장되지 않습니다.
설명
date_sunset( int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, ?float $latitude = null, ?float $longitude = null, ?float $zenith = null, ?float $utcOffset = null ): string|int|float|false
date_sunset()은 지정된 날짜(timestamp
로 지정됨) 및 위치의 일몰 시간을 반환합니다.
매개변수
timestamp
- 일몰 시간을 가져온 날짜의
timestamp
입니다. returnFormat
-
returnFormat
상수상수 설명 예시 SUNFUNCS_RET_STRING 결과를 문자열로 반환 16:46 SUNFUNCS_RET_DOUBLE 결과를 float로 반환 16.78243132 SUNFUNCS_RET_TIMESTAMP 결과를 int(타임스탬프)로 반환 1095034606 latitude
- 기본값은 북쪽이고 남쪽에는 음수 값을 전달합니다. 참조: date.default_latitude
longitude
- 기본값은 동쪽이고 서쪽에는 음수 값을 전달합니다. 참조: date.default_longitude
zenith
zenith
은 태양의 중심과 지표면에 수직인 선 사이의 각도입니다. 기본값은 date.sunrise_zenith입니다.일반적인
zenith
각도Angle 설명 90°50' 일출: 태양이 보이는 지점. 96° Civil twilight: conventionally used to signify the start of dawn. 102° Nautical twilight: the point at which the horizon starts being visible at sea. 108° Astronomical twilight: the point at which the sun starts being the source of any illumination. utcOffset
- 시간으로 지정됩니다.
returnFormat
이SUNFUNCS_RET_TIMESTAMP
인 경우utcOffset
은 무시됩니다.
반환 값
성공하면 지정된 returnFormat
으로 일몰 시간을 반환하고 실패하면 false
를 반환합니다. 실패에 대한 한 가지 잠재적인 이유는 해가 전혀 지지 않는다는 것인데, 이는 일년 중 일부 동안 극권 내부에서 발생합니다.
오류/예외
날짜/시간 함수에 대한 모든 호출은 시간대가 유효하지 않은 경우 E_WARNING
을 생성합니다. date_default_timezone_set()도 참조하십시오.
변경 로그
버전 | 설명 |
---|---|
8.1.0 | 이 함수는 date_sun_info()를 위해 더 이상 사용되지 않습니다. |
8.0.0 | latitude , longitude , zenith 및 utcOffset 은 이제 null을 허용합니다. |
Examples
예제 #1 date_sunset() 예제
<?php
/* calculate the sunset time for Lisbon, Portugal
Latitude: 38.4 North
Longitude: 9 West
Zenith ~= 90
offset: +1 GMT
*/
echo date("D M d Y"). ', sunset time : ' .date_sunset(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1);
?>
위의 예는 다음과 유사한 결과를 출력합니다.
Mon Dec 20 2004, sunset time : 18:13
예제 #2 No sunset
<?php
$solstice = strtotime('2017-12-21');
var_dump(date_sunset($solstice, SUNFUNCS_RET_STRING, 69.245833, -53.537222));
?>
위의 예는 다음을 출력합니다.
bool(false)
기타
- date_sunrise() - 주어진 날짜와 위치에 대한 일출 시간을 반환합니다.
- date_sun_info() - 일몰/일출 및 황혼 시작/종료에 대한 정보가 있는 배열을 반환합니다.