How to use date sunset in PHP

This article describe about date_sunset() Function in PHP.
  • 2211

date_sunset() Function

This function return the time of sunset for specific day and location.


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


Parameter Description
timestamp Required.
format Optional. Define how return the result.
  • SUNFUNCS_RET_STRING (returns the result as string. e.g. 18:26)
  • SUNFUNCS_RET_DOUBLE (returns the result as float. e.g. 18.78243437)
  • SUNFUNCS_RET_TIMESTAMP (returns the result as integer (timestamp). e.g. 4532689710)
latitude Optional. Defines the latitude of the location. The latitude defaults to North. If you want to define a South value, you have to pass a negative value.
longitude Optional. Defines the longitude of the location. The longitude defaults to East. If you want to Define a West value, you have to pass a negative value.
zenith Optional.
gmt_offset Optional. It define the difference between GMT and location in hour.


echo("Date: " . date("D M d Y") . "<br />");
echo("Sunset time: ");




You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.