This function returns the time of sunrise for a particular day and location.

Syntax: date_sunrise(timestamp,format,latitude,longitude,zenith,gmt_offset)

Description:

The first argument “timestamp” is Required.

The second argument “format” is Optional. It specifies how to return the result:

* SUNFUNCS_RET_STRING (returns the result as string. e.g. 16:46)
* SUNFUNCS_RET_DOUBLE (returns the result as float. e.g. 16.78243132)
* SUNFUNCS_RET_TIMESTAMP (returns the result as integer (timestamp). e.g. 1095034606)

The third argument “latitude” is Optional. It specifies the latitude of the location. The latitude defaults to North. If you want to specify a South value, you must pass a negative value.

The fourth argument “longitude” is Optional. It specifies the longitude of the location. The longitude defaults to East. If you want to specify a West value, you must pass a negative value.

The fifth argument “zenith” is Optional.

The sixth argument gmt_offset is Optional. It specifies the difference between GMT and local time in hours.

Example:
Code:


/* calculate the sunrise time for Lisbon, Portugal
Latitude: 38.4 North
Longitude: 9 West
Zenith ~= 90
offset: +1 GMT
*/

echo  date("D M d Y"). ', sunrise time : ' .date_sunrise(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1);

Output:

Sun Apr 10 2011, sunrise time : 07:09

eXTReMe Tracker