PHP date_sunset()関数
例
今日、ポルトガルのリスボンの日没時間を返します。
<?php
// Lisbon, Portugal:
// Latitude: 38.4 North, Longitude: 9 West
// Zenith ~= 90, offset: +1 GMT
echo("Lisbon, Portugal: Date: " . date("D M d Y"));
echo("<br>Sunset time: ");
echo(date_sunset(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));
?>
定義と使用法
date_sunset()関数は、指定された曜日と場所の日没時刻を返します。
ヒント:date_sunrise()関数を見て、指定した曜日と場所の日の出時刻を返します。
構文
date_sunset(timestamp, format, latitude, longitude, zenith, gmtoffset)
パラメータ値
Parameter | Description |
---|---|
timestamp | Required. Specifies the timestamp of the day from which the sunset time is taken |
format |
Optional. Specifies how to return the result:
|
latitude | Optional. Specifies the latitude of the location. Defaults to North. To specify a value for South, pass in a negative value |
longitude | Optional. Specifies the longitude of the location. Defaults to East. To specify a value for West, pass in a negative value |
zenith | Optional. Defaults to date.sunset_zenith |
gmtoffset | Optional. Specifies the difference between GMT and local time in hours |
技術的な詳細
戻り値: | 成功すると、指定された形式で 日没の時刻を返します。失敗するとFALSE |
---|---|
PHPバージョン: | 5歳以上 |
変更ログ: | PHP 5.1.0以降、この関数はE_STRICTおよびE_NOTICEタイムゾーンエラーを生成します |
❮PHPの日付/時刻リファレンス