How to use date sunset in PHP

This article describe about date_sunset() Function in PHP.
  • 2137

date_sunset() Function

This function return the time of sunset for specific day and location.

Syntax

date_sunset(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("Sunset time: ");
echo(date_sunset(time(),SUNFUNCS_RET_STRING,48.4,-7,80,2));
?>
</body>
</html>

 

Output


pic5.jpg

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

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.