How to date sunrise in PHP
This article describe about date_sunrise() Function in PHP.
date_sunrise() Function
This function return the time of sunrise of a specified day and location.
Syntax
date_sunrise(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. |
Example
<html>
</body>
<?php
echo("Date: " . date("D M d Y") . "<br />");
echo("Sunrise time: ");
echo(date_sunrise(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));
?>
</body>
</html> |
Output
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