date_sunrise() function in PHP

WBOY
Release: 2023-09-09 11:02:01
forward
1354 people have browsed it

date_sunrise() function in PHP

date_sunrise() function returns the sunrise time for a given date/location. If successful, it will return the sunrise time in the specified format. FALSE on failure.

Syntax

date_sunrise(timestamp,format,latitude,longitude,zenith,gmtoffset);
Copy after login

Parameters

  • Timestamp - Get the timestamp of the current day at sunrise time.

  • format - Specifies how to return the result:

    • SUNFUNCS_RET_STRING: Returns the result as a string. < /p>

    • SUNFUNCS_RET_DOUBLE: Returns the result in floating point form.

    • SUNFUNCS_RET_TIMESTAMP: Returns the result as an integer (timestamp)

      < /li>
  • Latitude - specified The latitude of the location. Latitude defaults to North. If you want to specify a south value, you must pass a negative value.

  • Longitude - The longitude of the specified location. Longitude defaults to east longitude. If you want to specify a west value, you must pass a negative value.

  • zenith - Defaults to date.sunrise_zenith

  • gmtoffset - Between GMT and local time time difference (in hours).

Return

The date_sunrise() function returns the sunrise time in the specified format after success. FALSE on failure.

Example

The following is an example-

Live demonstration

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

Output

The following is the output-

Date: Wed Oct 10 2018
Sunrise time: 07:43
Copy after login

Example

Let’s see another example-

Live Demonstration

Copy after login

Output

Here is the output-

string(5) "11:28"
Copy after login

The above is the detailed content of date_sunrise() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!