Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP date_sunset() Function

PHP date_sunset() Function

PHP Date/Time PHP Date/Time Reference Manual

Example

Return today's sunset time in Lisbon, Portugal:

Sunset time: "); echo(date_sunset(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1)); ?>

Run Example »


Definition and Usage

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

**Tip:** See the date_sunrise() function, which returns the sunrise time for a specified date and location.

Syntax

date_sunset(

timestamp,format,latitude,longitude,zenith,gmtoffset);

Parameters Description
timestamp Required. Specifies the timestamp of the date for which to calculate the sunset time.
format

Optional. Specifies how to return the result:

  • SUNFUNCS_RET_STRING (returns the result as a string, such as 16:46) (default)
  • SUNFUNCS_RET_DOUBLE (returns the result as a float, such as 16.78243132)
  • SUNFUNCS_RET_TIMESTAMP (returns the result as an integer timestamp, such as 1095034606)
  • | | *latitude* | Optional. Specifies the latitude of the location. North latitude is the default, so a negative value must be passed for south latitude. | | *longitude* | Optional. Specifies the longitude of the location. East longitude is the default, so a negative value must be passed for west longitude. | | *zenith* | Optional. Defaults to date.sunset_zenith. | | *gmtoffset* | Optional. Specifies the difference between GMT and local time, in hours. |

    Technical Details

    Return Value: On success, returns the sunrise time in the specified format Returns the sunset time, or FALSE on failure.
    PHP Version: 5+
    Changelog: Since PHP 5.1.0, this function raises E_STRICT and E_NOTICE time zone errors.

    PHP Date/Time PHP Date/Time Reference Manual