Home >>PHP Date Time Functions >PHP date_sunrise() Function
PHP date_sunrise() function is used to get the sunrise time for a specified day and location. It returns the sunrise time of the place based on the given latitude, longitude, zenith, and gmt offrise of that place.
Syntax:
date_sunrise(timestamp, format, latitude, longitude, zenith, gmtoffrise);
Parameter | Description |
---|---|
timestamp | This is a required parameter. This parameter defines the timestamp of the day from which the sunrise time is taken. |
format | This is an optional parameter. This parameter defines how to return the result. |
latitude | This is an optional parameter. This parameter defines the latitude of the location. |
longitude | This is an optional parameter. This parameter defines the longitude of the location. |
zenith | This is an optional parameter. This parameter defines zenith value. |
gmtoffrise | This is an optional parameter. This parameter defines the difference between GMT and local time in hours. |
Here is an example of date_sunrise() function in PHP:
<html> <body> <?php echo "Sunrise time: "; echo date_sunrise(time()); ?> </body> </html>
Example 2:
<html> <body> <?php echo "Date: ".date("D M d Y"); echo "<br>"; echo "Sunrise time in India today: "; echo(date_sunrise(time(),SUNFUNCS_RET_STRING,28,-77,90,-5.5)); ?> </body> </html>