YouTip LogoYouTip

Func Date Sunset

## Definition and Usage The **date_sunset()** function returns the sunset time for a given day and location. This function returns the sunset time in a specified format (default is string). ### Syntax ```php date_sunset(timestamp, format, latitude, longitude, zenith, gmt_offset); ``` ### Parameter Description | Parameter | Description | |--------------|-------------| | timestamp | Optional. Specifies a timestamp. Default is the current date and time. | | format | Optional. Specifies how to return the result:
β€’ **SUNFUNCS_RET_STRING** - Returns the result as a string (e.g., "16:46")
β€’ **SUNFUNCS_RET_DOUBLE** - Returns the result as a float (e.g., 16.766666666667)
β€’ **SUNFUNCS_RET_TIMESTAMP** - Returns the result as an integer (timestamp) (e.g., 1095034606) | | latitude | Optional. Specifies the latitude. Default is North; use negative values for South. | | longitude | Optional. Specifies the longitude. Default is East; use negative values for West. | | zenith | Optional. Default is **date.sunset_zenith** from php.ini.
Common zenith angles:
β€’ **90Β°50'**: Sunset: the sun's center is at the horizon
β€’ **96Β°**: Civil twilight
β€’ **102Β°**: Nautical twilight
β€’ **108Β°**: Astronomical twilight | | gmt_offset | Optional. Specifies the GMT offset in hours. | ### Return Value Returns the sunset time in the specified format on success, or **FALSE** on failure. ### Example Return today's sunset time: ```php ``` The output of the code above will be: ``` 16:46 ``` ### Example Return today's sunset time using all parameters: ```php ``` The output of the code above will be: ``` 18:14 ```
← Func Date Timezone GetFunc Date Sunrise β†’