PHP
HTML
CSS
JavaScript
jQuery
SQL
WordPress
PHP Reference

Quick Reference

The PHP date_sun_info() function returns an array containing information about sunset/sunrise and twilight begin/end, for a specified day and location.

				
					<?php
echo '<h3>Marina del Rey, CA: January 1, 2013</h3>';
$sun_info = date_sun_info(strtotime('2013-01-11'), 36.627861, -121.811211);

foreach ($sun_info as $key => $val) {
	echo $key . ': ' . date('H:i:s',$val) . '<br>';
}
?>
				
			

Output

				
					Marina del Rey, CA: January 1, 2013

sunrise: 15:19:15
sunset: 01:11:54
transit: 20:15:34
civil_twilight_begin: 14:51:03
civil_twilight_end: 01:40:06
nautical_twilight_begin: 14:19:09
nautical_twilight_end: 02:11:59
astronomical_twilight_begin: 13:48:02
astronomical_twilight_end: 02:43:07
				
			

Syntax

				
					date_sun_info(timestamp, latitude, longitude)
				
			

Parameters

ParameterDescription
timestampSpecifies a timestamp (required)
latitudeSpecifies the latitude in degrees (required)
longitudeSpecifies the longitude in degrees (required)

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

PHP
HTML
CSS
JavaScript
jQuery
SQL
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.