Returns the sunset time/Sunrise time of a given date and place

Source: Internet
Author: User
Tags local time php tutorial string format sunrise time

PHP Date_sunset () function
PHP date/time function
Definitions and usage
The Date_sunset () function returns the sunset time for the specified date and location.

Grammar
Date_sunset (timestamp,format,latitude,longitude,zenith,gmt_offset) parameter description
Timestamp required.
Format is optional. Specify how the results are returned:

Sunfuncs_ret_string (returns the result in STRING format, such as 16:46)
Sunfuncs_ret_double (returns the results in float format, such as 16.78243132)
Sunfuncs_ret_timestamp (returns the result in integer format (timestamp), such as 1095034606)

Latitude Optional. Specify the latitude of the place. By default, it means northern latitude. So if you want to specify latitude, you must pass a negative value.
Longitude optional. Specify the longitude of the place. By default, it means east longitude. So if you want to specify the longitude, you must pass a negative value.
Zenith Optional.
Gmt_offset Optional. Specify the difference between GMT and local time. Unit is an hour.
Example
<?php Tutorial
Calculate Sunrise time in Lisbon, Portugal
Latitude: 38.4 degrees north latitude
Longitude: 9 degrees west longitude
Zenith ~= 90
Offset: +1 GMT
Echo ("Date:"). Date ("D M D Y"). "<br/>");
Echo ("Sunrise Time:");
Echo (Date_sunset (Time (), sunfuncs_ret_string,38.4,-9,90,1));
?> output:

Date:tue 24 2006.
Sunrise time:18:44

PHP date_sunrise () function
PHP date/time function
Definitions and usage
The Date_sunrise () function returns the sunrise time for the specified date and location.

Grammar
Date_sunrise (timestamp,format,latitude,longitude,zenith,gmt_offset) parameter description
Timestamp required.
Format is optional. Specify how the results are returned:

Sunfuncs_ret_string (returns the result in STRING format, such as 16:46)
Sunfuncs_ret_double (returns the results in float format, such as 16.78243132)
Sunfuncs_ret_timestamp (returns the result in integer format (timestamp), such as 1095034606)

Latitude Optional. Specify the latitude of the place. By default, it means northern latitude. So if you want to specify latitude, you must pass a negative value.
Longitude optional. Specify the longitude of the place. By default, it means east longitude. So if you want to specify the longitude, you must pass a negative value.
Zenith Optional.
Gmt_offset Optional. Specify the difference between GMT and local time. Unit is an hour.
Example
<?php
Calculate Sunrise time in Lisbon, Portugal
Latitude: 38.4 degrees north latitude
Longitude: 9 degrees west longitude
Zenith ~= 90
Offset: +1 GMT
Echo ("Date:"). Date ("D M D Y"). "<br/>");
Echo ("Sunrise Time:");
Echo (Date_sunrise (Time (), sunfuncs_ret_string,38.4,-9,90,1));
?> output:

Date:tue 24 2006.
Sunrise time:08:52

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.