Copyright © tutorialspoint.com

PHP Function date_sun_info()

previous
Advertisements

Syntax

array date_sun_info ( int $time, float $latitude, float $longitude );

Definition and Usage

This function returns an array with information about sunset/sunrise and twilight begin/end.

Paramters

ParameterDescription
timeRequired. Timestamp.
latitudeRequired. Latitude in degrees.
longitudeRequired. Longitude in degrees.

Return Value

Returns array on success or FALSE on failure.

Example

Following is the usage of this function:

<?php
   $sun_info = date_sun_info(strtotime("2007-07-12"), 
                                      31.7667, 35.2333);
   foreach ($sun_info as $key => $val) {
       echo "$key: " . date("H:i:s", $val) . "\n";
   }
?> 

This will produce following result:

sunset: 10:46:47
transit: 03:44:44
civil_twilight_begin: 20:15:05
civil_twilight_end: 11:14:23
nautical_twilight_begin: 19:41:27
nautical_twilight_end: 11:48:00
astronomical_twilight_begin: 19:05:25
astronomical_twilight_end: 12:24:02
previous

Copyright © tutorialspoint.com