Hướng dẫn dùng sunrise angle trong PHP
(PHP 5 >= 5.1.2, PHP 7, PHP 8) date_sun_info — Returns an array with information about sunset/sunrise and twilight begin/end Descriptiondate_sun_info(int Parameterstimestamp Unix timestamp. latitude Latitude in degrees. longitude Longitude in degrees. Return Values Returns array on success or sunrise
The timestamp of the sunrise (zenith angle = 90°35'). sunset The timestamp of the sunset (zenith angle = 90°35'). transit The timestamp when the sun is at its zenith, i.e. has reached its topmost point. civil_twilight_begin The start of the civil dawn (zenith angle = 96°). It ends at sunrise . civil_twilight_end The end of the civil dusk (zenith angle = 96°). It starts at
sunset . nautical_twilight_begin The start of the nautical dawn (zenith angle = 102°). It ends at civil_twilight_begin . nautical_twilight_end The end of the nautical dusk (zenith angle = 102°). It starts at civil_twilight_end . astronomical_twilight_begin The start of the astronomical dawn (zenith angle = 108°). It ends at nautical_twilight_begin . astronomical_twilight_end The end of the astronomical dusk (zenith angle = 108°). It starts at nautical_twilight_end .
The values of the array elements are either UNIX timestamps, Changelog
ExamplesExample #1 A date_sun_info() example
The above example will output: sunrise: 05:52:11 sunset: 15:41:21 transit: 10:46:46 civil_twilight_begin: 05:24:08 civil_twilight_end: 16:09:24 nautical_twilight_begin: 04:52:25 nautical_twilight_end: 16:41:06 astronomical_twilight_begin: 04:21:32 astronomical_twilight_end: 17:12:00 Example #2 Polar night, with some processing
The above example will output: never: sunrise never: sunset 12:52:18 AKST: transit 10:53:19 AKST: civil_twilight_begin 14:51:17 AKST: civil_twilight_end 09:01:47 AKST: nautical_twilight_begin 16:42:48 AKST: nautical_twilight_end 07:40:47 AKST: astronomical_twilight_begin 18:03:49 AKST: astronomical_twilight_end Example #3 Midnight sun (Tromsø, Norway)
The above example will output: Array ( [sunrise] => 1 [sunset] => 1 [transit] => 1656240426 [civil_twilight_begin] => 1 [civil_twilight_end] => 1 [nautical_twilight_begin] => 1 [nautical_twilight_end] => 1 [astronomical_twilight_begin] => 1 [astronomical_twilight_end] => 1 ) Example #4 Calculating length of day (Kyiv)
The above example will output: There are no user contributed notes for this page. |