PHP date_sunset() Function

What is a Date Sunset Function?

Explanation

The "date_sunset()" function returns an array with the information about the sunset/sunrise and twilight begin/end.

Syntax:


date_sunset(timestamp,format,latitude,longitude,zenith,gmt_offset)

In the above syntax "$time" is the timestamp, logitude,latitude in degrees.

Example :


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

Sunset time: 20:56

In the above example the date_sunset() function will display sunset time for the given timetamp, "SUNFUNCS_RET_STRING" returns the sunset time as a string, for the given latitude,longitude.

Note :

(PHP 5)

PHP Topics


Ask Questions

Ask Question