Php-function-date-sun-info
提供:Dev Guides
PHP-関数date_sun_info()
構文
array date_sun_info ( int $time, float $latitude, float $longitude );
定義と使い方
この関数は、日没/日の出と夕暮れの開始/終了に関する情報を含む配列を返します。
パラメーター
Sr.No | Parameter & Description |
---|---|
1 |
time(Required) タイムスタンプ。 |
2 |
latitude(Required) 度単位の緯度。 |
3 |
longitude(Required) 度単位の経度。 |
戻り値
成功すると配列を返し、失敗するとFALSEを返します。
例
以下は、この機能の使用法です-
<?php
$sun_info = date_sun_info(strtotime("2017-07-12"), 31.7667, 35.2333);
foreach ($sun_info as $key => $val) {
echo "$key: " . date("H:i:s", $val) . "\n";
}
?>
これは、次の結果を生成します-
sunrise: 02:42:53 sunset: 16:46:42 transit: 09:44:48 civil_twilight_begin: 02:15:18 civil_twilight_end: 17:14:17 nautical_twilight_begin: 01:41:42 nautical_twilight_end: 17:47:53 astronomical_twilight_begin: 01:05:42 astronomical_twilight_end: 18:23:53