PHP date_sunrise() 函數
實例
返回葡萄牙里斯本今天的日出時間:
<?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>Sunrise time: ");
echo(date_sunrise(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));
?>
// 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>Sunrise time: ");
echo(date_sunrise(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));
?>
定義和用法
date_sunrise() 函數返回指定日期與地點的日出時間。
提示:請參閱 date_sunset() 函數,返回指定日期與地點的日落時間。
語法
date_sunrise(timestamp,format,latitude,longitude,zenith,gmtoffset);
| 參數 | 描述 |
|---|---|
| timestamp | 必需。規定要計算日出時間的日期時間戳。 |
| format |
可選。規定如何返回結果:
|
| latitude | 可選。規定地點的緯度。默認是指北緯。因此如果要指定南緯,必須傳遞一個負值。 |
| longitude | 可選。規定地點的經度。默認是指東經。因此如果要指定西經,必須傳遞一個負值。 |
| zenith | 可選。默認為 date.sunrise_zenith。 |
| gmtoffset | 可選。規定 GMT 與本地時間的差值。單位是小時。 |
技術細節
| 返回值: | 如果成功,則以指定的 format 返回日出時間。如果失敗則返回 FALSE。 |
|---|---|
| PHP 版本: | 5+ |
| 更新日誌: | 從 PHP 5.1.0 開始,該函數報 E_STRICT 和 E_NOTICE 時區錯誤。 |
PHP Date/Time 參考手冊
