ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
# PHP date_sunset() 函数 ## 定义和用法 date_sunset() 函数返回指定的日期与地点的日落时间。 ### 语法 ``` date_sunset(timestamp,format,latitude,longitude,zenith,gmt_offset) ``` | 参数 | 描述 | | --- | --- | | timestamp | 必需。 | | format | 可选。规定如何返回结果: `SUNFUNCS_RET_STRING` (以 string 格式返回结果,比如 16:46) `SUNFUNCS_RET_DOUBLE` (以 float 格式返回结果,比如 16.78243132) `SUNFUNCS_RET_TIMESTAMP` (以 integer 格式(时间戳)返回结果,比如 1095034606) | | latitude | 可选。规定地点的纬度。默认是指北纬。因此如果要指定南纬,必须传递一个负值。 | | longitude | 可选。规定地点的经度。默认是指东经。因此如果要指定西经,必须传递一个负值。 | | zenith | 可选。 | | gmt_offset | 可选。规定 GMT 与本地时间的差值。单位是小时。 | ## 例子 ``` <?php //计算葡萄牙里斯本的日出时间 //Latitude: 北纬 38.4 度 //Longitude: 西经 9 度 //Zenith ~= 90 //offset: +1 GMT echo("Date: " . date("D M d Y") . "<br />"); echo("Sunrise time: "); echo(date_sunset(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1)); ?> ``` 输出: ``` Date: Tue Jan 24 2006 Sunrise time: 18:44 ```