date_sunset


 

date_sunset

date_sunset function returns the sunset time for a given day and location. The day is specified as a timestamp. It returns the sunset time in a specified format on success, or FALSE on failure.

date_sunset function returns the sunset time for a given day and location. The day is specified as a timestamp. It returns the sunset time in a specified format on success, or FALSE on failure.

date_sunset() in PHP

date_sunset function returns the sunset time for a given day and location. The day is specified as a timestamp. It returns the sunset time in a specified format on success, or FALSE on failure.

Syntax of date_sunset() in PHP

mixed date_sunset ( int $timestamp [, int $format= SUNFUNCS_RET_STRING [, float $latitude= ini_get("date.default_latitude") [, float $longitude= ini_get("date.default_longitude") [, float $zenith= ini_get("date.sunset_zenith") [, float $gmt_offset= 0 ]]]]] )

Parameters of date_sunset() in PHP

timestamp - The timestamp of the day from which the sunset time is taken. . 

format - the format of the constant is given below:
SUNFUNCS_RET_STRING returns the result as string 12:26
SUNFUNCS_RET_DOUBLE returns the result as float 11.51526894
SUNFUNCS_RET_TIMESTAMP returns the result as integer (timestamp) 1095034606

latitude - Defaults to North, pass in a negative value for South. 

longitude - Defaults to East, pass in a negative value for West. 

zenith - Default: date.sunset_zenith

gmtoffset - Specified in hours.

Example: 

<?php

/*calculate the sunset time for Delhi/India

Latitude: 28.61 North
Longitude: 77.23 East
Zenith ~= 90
offset: +5.50 GMT
*/

echo date("D M d Y"). ', sunset time : ' .date_sunset(time(), SUNFUNCS_RET_STRING, 28.61, 77.23, 90, 1);

?>

The above example will output something similar to:

Wed Aug 26 2009, sunset time : 18:49

Ads