وظيفة date_sunset() في PHP

مثال

تقديم وقت الغروب اليومي في لشبونة، البرتغال:

<?php
// 上海,中国:
// 维度:北纬 31.22 ,经度:西经 121.47
// 天顶 ~= 90,偏移:+8 GMT
echo("上海,中国:日期:" . date("D M d Y"));
echo("<br>日出时间:");
echo(date_sunrise(time(),SUNFUNCS_RET_STRING,31.22,121.47,90,8));
?>

Run Example

Definition and Usage

The date_sunset() function returns the sunset time for the specified date and location.

Tip:See also date_sunrise() Function, returns the sunrise time for the specified date and location.

Syntax

date_sunset(timestamp,format,latitude,longitude,zenith,gmtoffset);
Parameters Description
timestamp Required. Specifies the date and time timestamp to calculate the sunset time.
format

Optional. Specifies how to return the result:

  • SUNFUNCS_RET_STRING (returns the result as a string, for example, 16:46) (default)
  • SUNFUNCS_RET_DOUBLE (returns the result as a floating-point number, for example, 16.78243132)
  • SUNFUNCS_RET_TIMESTAMP (returns the result as an integer (timestamp), for example, 1095034606)
latitude Optional. Specifies the latitude of the location. Defaults to North Latitude. To specify South Latitude, please pass a negative value.
longitude Optional. Specifies the longitude of the location. Defaults to East Longitude. To specify West Longitude, please pass a negative value.
zenith Optional. Defaults to date.sunset_zenith.
gmtoffset Optional. Specifies the difference between GMT and local time in hours.

Technical Details

Return Value: If successful, returns the sunset time in the specified format. If failed, returns FALSE.
PHP Version: 5+
Update Log: Starting from PHP 5.1.0, the function reports E_STRICT and E_NOTICE timezone errors when it occurs.