Return to Lisbon, Portugal Today's sunrise time:
<?php// Lisbon, Portugal:// Latitude: 38.4 North, Longitude: 9 West// Zenith ~= 90, offset: +1 GMTecho("Lisbon, Portugal: Date: " . date("DM d Y") );echo("<br>Sunrise time: ");echo(date_sunrise(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));?>The date_sunrise() function returns the sunrise time for a specified date and location.
Tip: See the date_sunset() function, which returns the sunset time for a specified date and location.
date_sunrise( timestamp,format,latitude,longitude,zenith,gmtoffset);
parameter | describe |
---|---|
timestamp | Required. Specifies the date timestamp for which the sunrise time is to be calculated. |
format | Optional. Specify how to return results: SUNFUNCS_RET_STRING (returns the result in string format, such as 16:46) (default) SUNFUNCS_RET_DOUBLE (returns the result in float format, such as 16.78243132) SUNFUNCS_RET_TIMESTAMP (returns the result in integer format (timestamp), such as 1095034606) |
latitude | Optional. Specifies the latitude of the location. The default is northern latitude. Therefore if you want to specify south latitude, you must pass a negative value. |
longitude | Optional. Specifies the longitude of the location. The default is east longitude. Therefore if you want to specify west longitude, you must pass a negative value. |
zenith | Optional. The default is date.sunrise_zenith. |
gmtoffset | Optional. Specifies the difference between GMT and local time. The unit is hours. |
Return value: | If successful, returns the sunrise time in the specified format . Returns FALSE on failure. |
---|---|
PHP version: | 5+ |
Update log: | Starting from PHP 5.1.0, this function reports E_STRICT and E_NOTICE time zone errors. |