zenith is the angle between the center of the sun
and a line perpendicular to earth's surface. It defaults to
date.sunset_zenith

Common zenith angles

Angle

Description

90°50'

Sunset: the point where the sun becomes invisible.

96°

Civil twilight: conventionally used to signify the end of dusk.

102°

Nautical twilight: the point at which the horizon ends being visible at sea.

108°

Astronomical twilight: the point at which the sun ends being the source of any illumination.

gmtoffset

Specified in hours.
The gmtoffset is ignored, if
format is
SUNFUNCS_RET_TIMESTAMP.

Errors/Exceptions

Every call to a date/time function will generate a E_NOTICE
if the time zone is not valid, and/or a E_STRICT
or E_WARNING message
if using the system settings or the TZ environment
variable. See also date_default_timezone_set()

Changelog

Version

Description

5.1.0

Now issues the E_STRICT and E_NOTICE
time zone errors.

Return Values

Returns the sunset time in a specified format on
success or FALSE on failure. One potential reason for failure is that the
sun does not set at all, which happens inside the polar circles for part of
the year.

I use an IP to location database to determine the visitor's approximate latitude and longitude and then serve them a day or night color scheme based on whether it is before civil dawn or dusk. I've had problems when not specifying the timezone, specifically a 1 hour error, so I use GMT.