当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > date_sunset() 函数
The date_sunset() function returns the time of sunset for a specified day and location.
date_sunset()函数的作用是:返回给定的日期与地点的日落时间。
date_sunset(timestamp,format,latitude,longitude,zenith,gmt_offset) |
| Parameter参数 | Description描述 |
|---|---|
| timestamp | Required. 必要参数 |
| format | Optional. Specifies how to return the result:
|
| latitude | Optional. Specifies the latitude of the location. The latitude defaults to North. If you want to specify a South value, you must pass a negative value. |
| longitude | Optional. Specifies the longitude of the location. The longitude defaults to East. If you want to specify a West value, you must pass a negative value. |
| zenith | Optional. 可选参数 |
| gmt_offset | Optional. Specifies the difference between GMT and local time in hours. |
<?php
//Calculate the sunset time for Lisbon, Portugal
//Latitude: 38.4 North
//Longitude: 9 West
//Zenith ~= 90
//offset: +1 GMT
echo("Date: " . date("D M d Y") . "<br />");
echo("Sunset time: ");
echo(date_sunset(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));
?> |
The output of the code above could be:
上述代码将输出下面的结果:
Date: Tue Jan 24 2006 Sunset time: 18:44 |
评论 (0) All