PHP | date_sun_info() Function Last Updated : 03 Mar, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The date_sun_info() is an inbuilt function in PHP which is used to find the information about sunset/sunrise and twilight begin/end for a specified day and location.Syntax: array date_sun_info($timestamp, $latitude, $longitude) Parameters: This function accepts three parameters as mentioned above and described below: $timestamp: It is a mandatory parameter which specifies the timestamp of the day from which the sunrise time is taken.$latitude: It is an mandatory parameter which specifies the latitude of the location. By default, it set as North. To specify a value for South, pass in a negative value.$longitude: It is an mandatory parameter which specifies the longitude of the location. By defaults, it set as East. To modify a value for West, pass in a negative value. Return Value: It returns an array containing information about sunset/sunrise and twilight begin/end, for a specified day and location and returns False on failure.Exceptions: In PHP versions 5.2.2 the order of parameters $latitude and $longitude has been swapped.Below programs illustrate the date_sun_info() function.Program 1: php <?php // PHP program to print information // about sunset/sunrise and twilight // begin/end for specified location // New Delhi India /* ********New Delhi******** Latitude = 28.6139° N Longitude = 77.2090° E */ $arr = date_sun_info(strtotime("June-26-2018"), 28.61, 77.2090 ); foreach ($arr as $key => $val) { echo "$key: " . date("H:i:s", $val) . "\n"; } ?> Output: sunrise: 23:55:58 sunset: 13:53:02 transit: 06:54:30 civil_twilight_begin: 23:29:08 civil_twilight_end: 14:19:52 nautical_twilight_begin: 22:56:35 nautical_twilight_end: 14:52:25 astronomical_twilight_begin: 22:21:59 astronomical_twilight_end: 15:27:01 Program 2: php <?php // PHP program to print information // about sunset/sunrise and twilight // begin/end for specified location // USA Washington, D.C. // Latitude = 38.9072° N // Longitude = 77.0369° W $arr = date_sun_info(strtotime("June-26-2018"), 38.9072, 77.0369 ); foreach ($arr as $key => $val) { echo "$key: " . date("H:i:s", $val) . "\n"; } ?> Output: sunrise: 23:28:58 sunset: 14:21:24 transit: 06:55:11 civil_twilight_begin: 22:57:03 civil_twilight_end: 14:53:20 nautical_twilight_begin: 22:16:45 nautical_twilight_end: 15:33:38 astronomical_twilight_begin: 21:30:31 astronomical_twilight_end: 16:19:51 Related Articles: PHP | date_sunrise() FunctionPHP | date_modify() Function Reference: http://php.net/manual/en/function.date-sun-info.php Comment More infoAdvertise with us Next Article PHP date_sub() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-date-time PHP-function Similar Reads PHP date_sub() Function The date_sub() function is an inbuilt function in PHP that is used to subtract days, months, years, hours, minutes, and seconds from given date. This function returns a DateTime object on success and FALSE on failure. Syntax: date_sub($object, $interval)Parameters: The date_sub() function accepts tw 2 min read PHP | date_sunset() Function The date_sunset() is an inbuilt function in PHP which is used to find the sunset time for a specified day and location. Syntax: date_sunset ( $timestamp, $format, $latitude, $longitude, $zenith, $gmtoffset ) Parameters: This function accepts four parameters as mentioned above and described below. $t 2 min read PHP | date_sunrise() Function The date_sunrise() is an inbuilt function in PHP which is used to find the sunrise time for a specified day and location. This function returns the time of the sunrise, in the specified format, on success. FALSE on failure. Syntax: date_sunrise ( $timestamp, $format, $latitude, $longitude, $zenith, 2 min read PHP | cal_info( ) Function The cal_info() function in PHP is an inbuilt function that is used to return information about a specified calendar. The cal_info() function returns an array that contains the calname, month, abbrevmonth and maxdaysinmonth, and calsymbol. It takes the calendar as a parameter and returns the informat 2 min read PHP | date_isodate_set() Function The date_isodate_set() function is an inbuilt function in PHP which is used to sets the ISO (International Organization for Standardization ) date. This function set the date according to the ISO 8601 standard, using weeks and day offsets rather than specific dates. Syntax: Procedural style: date_is 2 min read PHP | date_modify() Function The date_modify() function is an inbuilt function in PHP. Through the help of this function, we can modify or can alter the timestamp of DateTime object. The DateTime object and string modify are parameters in the calling function. Syntax: date_modify(DateTime $object, string $modify); Parameters: T 2 min read Like