Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP date_sunrise() Function

PHP date_sunrise() Function

PHP Date/Time PHP Date/Time Reference Manual

Example

Return today's sunrise time in Lisbon, Portugal:

Sunrise time: "); echo(date_sunrise(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1)); ?>

Run Example »


Definition and Usage

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.

Syntax

date_sunrise(

timestamp,format,latitude,longitude,zenith,gmtoffset);

Parameters Description
timestamp Required. Specifies the timestamp of the date for which to calculate the sunrise time.
format

Optional. Specifies how to return the result:

  • SUNFUNCS_RET_STRING (returns the result as a string, such as 16:46) (default)
  • SUNFUNCS_RET_DOUBLE (returns the result as a float, such as 16.78243132)
  • SUNFUNCS_RET_TIMESTAMP (returns the result as an integer timestamp, such as 1095034606)
  • | | *latitude* | Optional. Specifies the latitude of the location. North latitude is the default, so a negative value must be passed for south latitude. | | *longitude* | Optional. Specifies the longitude of the location. East longitude is the default, so a negative value must be passed for west longitude. | | *zenith* | Optional. Defaults to date.sunrise_zenith. | | *gmtoffset* | Optional. Specifies the difference between GMT and local time, in hours. |

    Technical Details

    Return Value: On success, returns the sunrise time in the specified format format. Returns FALSE on failure.
    PHP Version: 5+
    Changelog: Since PHP 5.1.0, this function raises E_STRICT and E_NOTICE time zone errors.

    PHP Date/Time PHP Date/Time Reference Manual