PHP date_sunset() function
Complete PHP Date Reference
Definition and Usage
The date_sunset() function returns the time of sunset for a specified day
and location.
Syntax
date_sunset(timestamp,format,latitude,longitude,zenith,gmt_offset)
|
Parameter |
Description |
timestamp |
Required. |
format |
Optional. 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)
|
latitude |
Optional. 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. |
longitude |
Optional. 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. |
zenith |
Optional. |
gmt_offset |
Optional. Specifies the difference between GMT and local time in hours. |
Example
<?php
//Calculate the sunset time for Lisbon, Portugal
//Latitude: 38.4 North
//Longitude: 9 West
//Zenith ~= 90
//offset: +1 GMT
echo("Date: " . date("D M d Y") . "<br />");
echo("Sunset time: ");
echo(date_sunset(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));
?>
|
The output of the code above could be:
Date: Tue Jan 24 2006
Sunset time: 18:44
|
Complete PHP Date Reference
The Altova MissionKit is a suite of intelligent XML tools, including:
XMLSpy® – industry-leading XML editor
- Support for all XML-based technologies
- Graphical editing views, powerful debuggers, code generation, & more
MapForce® – graphical data mapping tool
- Drag-and-drop data conversion with code generation
- Support for XML, DBs, EDI, Excel® 2007, text, Web services
StyleVision® – visual stylesheet designer
- Drag-and-drop stylesheet design for XML & databases
- Output to HTML, PDF, RTF, Word 2007, & more
And more…
Try before you buy with a free fully functional 30-day trial
Download today
|
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.
The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).
|
|