date_sun_info

PHP 5 >= 5.1.2, PHP 7, PHP 8
date_sun_info - Returns an array with information about sunset/sunrise and twilight begin/end
Manual
Code Examples

date_sun_info( int$timestamp, float$latitude, float$longitude ): array

Parameters

timestamp

Unix timestamp.

latitude

Latitude in degrees.

longitude

Longitude in degrees.

Return Values

Returns array on success or false on failure. The structure of the array is detailed in the following list:

sunrise

The timestamp of the sunrise (zenith angle = 90°35').

sunset

The timestamp of the sunset (zenith angle = 90°35').

transit

The timestamp when the sun is at its zenith, i.e. has reached its topmost point.

civil_twilight_begin

The start of the civil dawn (zenith angle = 96°). It ends at sunrise.

civil_twilight_end

The end of the civil dusk (zenith angle = 96°). It starts at sunset.

nautical_twilight_begin

The start of the nautical dawn (zenith angle = 102°). It ends at civil_twilight_begin.

nautical_twilight_end

The end of the nautical dusk (zenith angle = 102°). It starts at civil_twilight_end.

astronomical_twilight_begin

The start of the astronomical dawn (zenith angle = 108°). It ends at nautical_twilight_begin.

astronomical_twilight_end

The end of the astronomical dusk (zenith angle = 108°). It starts at nautical_twilight_end.

The values of the array elements are either UNIX timestamps, false if the sun is below the respective zenith for the whole day, or true if the sun is above the respective zenith for the whole day.

Related Functions

Example of date_sun_info

Show all examples for date_sun_info

PHP Version:


Function date_sun_info:

Date and Time Functions

Most used PHP functions