PHP | date_sun_info() Function Last Updated : 03 Mar, 2021 Comments Improve Suggest changes 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_sun_info() 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 PHP | DateTime sub() Function The DateTime::sub() function is an inbuilt function in PHP which is used to subtract a number of days, months, years, hours, minutes and seconds from a created DateTime object. Syntax: Object oriented style: DateTime DateTime::sub( DateInterval interval ) Procedural style: DateTime date_sub( DateTim 2 min read PHP | DateTime modify() Function The DateTime::modify() function is an inbuilt function in PHP which is used to modify or can alter the timestamp of a DateTime object. Syntax: Object oriented style: DateTime DateTime::modify( string $modify ) Procedural style: DateTime date_modify( DateTime $object, string $modify ) Parameters: Thi 2 min read PHP | date_date_set() Function The date_date_set() function is an inbuilt function in PHP which is used to set a new Date. This function has four parameters $object, $year, $month and $day and returns DateTime object on success or false on failure. The date_date_set() function is an alias of DateTime::setDate() function. Syntax: 2 min read PHP | date_parse() Function The date_parse() is an inbuilt function in PHP which is used to find the detailed information about a specified date. This function returns an associative array of detailed information for a specified date on success and returns FALSE on failure Syntax: date_parse($date) Parameters Used: The date_pa 2 min read Like