PHP date_sunrise() Function

What is a Date Sunrise Function?

Explanation

The "date_sunrise()" function returns the time of sunrise for a given day,location.

Syntax:


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

In the above syntax the basic values are "timestamp" from which the sunrise is calculated, the format of the values returned would be in string, double, timestamp. The "Latitude" for south should be a negative value, for north a positive value. The "Longitude" for east should be a negative value, for west should be positive value. Other values are "zenith", "gmtoffset" to be specified in hours.

Example :


<?php
echo ("Date: " date("D M d Y").',)
echo("Sunrise time: ");
echo (date_sunrise(time(), SUNFUNCS_RET_STRING,38.4,-9,90,1);
?>
Result :

Date: Mon Dec 20 2004
Sunrise time : 08:54

In the above example, using date_sunrise() function, the sunrise time is calculated for Lisbon, Portugal, with a Latitude: 38.4 North, Longitude: 9 West,Zenith ~= 90, offset: +1 GMT.

Note :

(PHP 5)

PHP Topics


Ask Questions

Ask Question