PHP date_sunrise() 函數(shù)
定義和用法
date_sunrise() 函數(shù)返回指定的日期與地點(diǎn)的日出時(shí)間。
語(yǔ)法
date_sunrise(timestamp,format,latitude,longitude,zenith,gmt_offset)
參數(shù) | 描述 |
---|---|
timestamp | 必需。 |
format |
可選。規(guī)定如何返回結(jié)果:
|
latitude | 可選。規(guī)定地點(diǎn)的緯度。默認(rèn)是指北緯。因此如果要指定南緯,必須傳遞一個(gè)負(fù)值。 |
longitude | 可選。規(guī)定地點(diǎn)的經(jīng)度。默認(rèn)是指東經(jīng)。因此如果要指定西經(jīng),必須傳遞一個(gè)負(fù)值。 |
zenith | 可選。 |
gmt_offset | 可選。規(guī)定 GMT 與本地時(shí)間的差值。單位是小時(shí)。 |
例子
<?php //計(jì)算葡萄牙里斯本的日出時(shí)間 //Latitude: 北緯 38.4 度 //Longitude: 西經(jīng) 9 度 //Zenith ~= 90 //offset: +1 GMT echo("Date: " . date("D M d Y") . "<br />"); echo("Sunrise time: "); echo(date_sunrise(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1)); ?>
輸出:
Date: Tue Jan 24 2006 Sunrise time: 08:52