date_sun_info


php apg

RETURNS the information on the moments of remarkable positions of the sun, according to TIME, LATITUDE and LONGITUDE of the LOCAL.


May experience difficulties in displaying characters outside of the English language when preceded with the setlocale function.



<?php

arr date_sun_info 
int $timestamp float $latitude float $longitude )


where,

$timestamp The local timestamp

$latitude 
The local LATITUDE in degrees

$longitude 
The local LONGITUDE in degrees

?>

 $timestamp 


The UNIX local timestamp.



 $latitude 


The local latitude, expressed in degrees as floating point value.



 $longitude 


The local longitude, expressed in degrees as floating point value.



RETURNED VALUES

RETURNED VALUES
ARRAY INDEXES MEANING
[sunrise] The time of the sunrise
(zenith angle = 90°35')
[sunset] The time of the sunset
(zenith angle = 90°35')
[transit] The time 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 dawnV(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
ed48




This function returns FALSE on failure.



  1 EXERCISE   

<?php

if (function_exists('date_sun_info'))
{

setlocale(LC_ALL"pt_PT.utf-8""portuguese""ptg"); 
date_default_timezone_set('Europe/Lisbon');
$tz_01 date_default_timezone_get();

echo 
'setlocale(LC_TIME, "pt_PT.utf-8", "portuguese", "ptg")<br><br>';
echo 
$tz_01 '<br><br>';

$stnow strtotime("now");

$stlat 38.52859528204384;
$stlong = -8.891243934631348;
// Jardim do Bonfim, Setubal - Portugal

$arr_sun_info date_sun_info($stnow$stlat$stlong);

echo 
'LATITUDE = ' $stlat '<br>';

echo 
'LONGITUDE = ' $stlong '<br><br>';

$stsrise $arr_sun_info['sunrise'];
$stssrise strftime("%Hh %Mmin %Ss"$stsrise);

$stsset $arr_sun_info['sunset'];
$stssset strftime("%Hh %Mmin %Ss"$stsset);

$ststrns $arr_sun_info['transit'];
$stsstrns strftime("%Hh %Mmin %Ss"$ststrns);

$stctwbeg $arr_sun_info['civil_twilight_begin'];
$stsctwbeg strftime("%Hh %Mmin %Ss"$stctwbeg); 

$stctwend $arr_sun_info['civil_twilight_end'];
$stsctwend strftime("%Hh %Mmin %Ss"$stctwend); 

$stntwbeg $arr_sun_info['nautical_twilight_begin'];
$stsntwbeg strftime("%Hh %Mmin %Ss"$stntwbeg);

$stntwend $arr_sun_info['nautical_twilight_end'];
$stsntwend strftime("%Hh %Mmin %Ss"$stntwend);

$statwbeg $arr_sun_info['astronomical_twilight_begin'];
$stsatwbeg strftime("%Hh %Mmin %Ss"$statwbeg); 

$statwend $arr_sun_info['astronomical_twilight_end'];
$stsatwend strftime("%Hh %Mmin %Ss"$statwend); 

?>
Setubal, Portugal<br>
Hoje: <?php echo strftime("%A, %d de %B de %Y"time()); ?>
<br><br>
<table width="100%" align="center" border="1" cellpadding="5" cellspacing="5">
<tbody><tr><td>EVENT INDEXES</td><td>TIMESTAMP</td>
<td>MEANING</td><td>TIME OF DAY</td></tr>
<tr><td width="27%">[sunrise]</td>
<td width="13%"><?php echo $stsrise?></td>
<td width="28%">The time of the sunrise</td>
<td><?php echo $stssrise?></td></tr>
<tr><td>[sunset]</td>
<td><?php echo $stsset?></td>
<td>The time of the sunset</td>
<td><?php echo $stssset?></td></tr>
<tr><td>[transit]</td>
<td><?php echo $ststrns?></td>
<td>The time when the sun is at its zenith</td>
<td><?php echo $stsstrns?></td></tr>
<tr><td>[civil_twilight_begin]</td>
<td><?php echo $stctwbeg?></td>
<td>The start of the civil dawn</td>
<td><?php echo $stsctwbeg?></td></tr>
<tr><td>[civil_twilight_end]</td>
<td><?php echo $stctwend?></td>
<td>The end of the civil dusk</td>
<td><?php echo $stsctwend?></td></tr>
<tr><td>[nautical_twilight_begin]</td>
<td><?php echo $stntwbeg?></td>
<td>The start of the nautical dawn</td>
<td><?php echo $stsntwbeg?></td></tr>
<tr><td>[nautical_twilight_end]</td>
<td><?php echo $stntwend?></td>
<td>The end of the nautical dusk</td>
<td><?php echo $stsntwend?></td></tr>
<tr><td>[astronomical_twilight_begin]</td>
<td><?php echo $statwbeg?></td>
<td>The start of the astronomical dawn</td>
<td><?php echo $stsatwbeg?></td></tr>
<tr><td>[astronomical_twilight_end]</td>
<td><?php echo $statwend?></td>
<td>The end of the astronomical dusk</td>
<td><?php echo $stsatwend?></td></tr>
<tr><td colspan="4">ed48</td></tr></tbody></table>
<?php
}
else
{
echo 
'Function not available on this environment!<br><br>';
}
?>


  2 EXERCISE   

<?php

setlocale
(LC_ALL"pt_BR.utf-8""portuguese-brazil""ptb"); 
date_default_timezone_set('America/Sao_Paulo');
$tz_02 date_default_timezone_get();

echo 
'setlocale(LC_ALL, "pt_BR.utf-8", "portuguese-brazil", "ptb")<br><br>';
echo 
$tz_02 '<br><br>';

$stnow strtotime("now");

$stlat = -23.6824124;
$stlong = -46.5952992;
// Av Piraporinha - Diadema, São Paulo - Brasil

$arr_sun_info date_sun_info($stnow$stlat$stlong);

echo 
'LATITUDE = ' $stlat '<br>';

echo 
'LONGITUDE = ' $stlong '<br><br>';

$stsrise $arr_sun_info['sunrise'];
$stssrise strftime("%Hh %Mmin %Ss"$stsrise);

$stsset $arr_sun_info['sunset'];
$stssset strftime("%Hh %Mmin %Ss"$stsset);

$ststrns $arr_sun_info['transit'];
$stsstrns strftime("%Hh %Mmin %Ss"$ststrns);

$stctwbeg $arr_sun_info['civil_twilight_begin'];
$stsctwbeg strftime("%Hh %Mmin %Ss"$stctwbeg); 

$stctwend $arr_sun_info['civil_twilight_end'];
$stsctwend strftime("%Hh %Mmin %Ss"$stctwend); 

$stntwbeg $arr_sun_info['nautical_twilight_begin'];
$stsntwbeg strftime("%Hh %Mmin %Ss"$stntwbeg);

$stntwend $arr_sun_info['nautical_twilight_end'];
$stsntwend strftime("%Hh %Mmin %Ss"$stntwend);

$statwbeg $arr_sun_info['astronomical_twilight_begin'];
$stsatwbeg strftime("%Hh %Mmin %Ss"$statwbeg); 

$statwend $arr_sun_info['astronomical_twilight_end'];
$stsatwend strftime("%Hh %Mmin %Ss"$statwend); 

?>
São Paulo, Brasil<br>
Hoje: <?php echo strftime("%A, %d de %B de %Y"time()); ?>
<br><br>
<table width="100%" align="center" border="1" cellpadding="5" cellspacing="5">
<tbody><tr><td>EVENT INDEXES</td><td>TIMESTAMP</td><td>MEANING</td>
<td>TIME OF DAY</td></tr>
<tr><td width="27%">[sunrise]</td>
<td width="13%"><?php echo $stsrise?></td>
<td width="28%">The time of the sunrise</td>
<td><?php echo $stssrise?></td></tr>
<tr><td>[sunset]</td>
<td><?php echo $stsset?></td>
<td>The time of the sunset</td>
<td><?php echo $stssset?></td></tr>
<tr><td>[transit]</td>
<td><?php echo $ststrns?></td>
<td>The time when the sun is at its zenith</td>
<td><?php echo $stsstrns?></td></tr>
<tr><td>[civil_twilight_begin]</td>
<td><?php echo $stctwbeg?></td>
<td>The start of the civil dawn</td>
<td><?php echo $stsctwbeg?></td></tr>
<tr><td>[civil_twilight_end]</td>
<td><?php echo $stctwend?></td>
<td>The end of the civil dusk</td>
<td><?php echo $stsctwend?></td></tr>
<tr><td>[nautical_twilight_begin]</td>
<td><?php echo $stntwbeg?></td>
<td>The start of the nautical dawn</td>
<td><?php echo $stsntwbeg?></td></tr>
<tr><td>[nautical_twilight_end]</td>
<td><?php echo $stntwend?></td>
<td>The end of the nautical dusk</td>
<td><?php echo $stsntwend?></td></tr>
<tr><td>[astronomical_twilight_begin]</td>
<td><?php echo $statwbeg?></td>
<td>The start of the astronomical dawn</td>
<td><?php echo $stsatwbeg?></td></tr>
<tr><td>[astronomical_twilight_end]</td>
<td><?php echo $statwend?></td>
<td>The end of the astronomical dusk</td>
<td><?php echo $stsatwend?></td></tr>
<tr><td colspan="4">ed48</td></tr></tbody></table>


  3 EXERCISE   

<?php

setlocale
(LC_ALL"en_US""american""american english""american-english""english-american""english-us""english-usa""enu""us""usa");  
date_default_timezone_set('America/New_York');
$tz_03 date_default_timezone_get();

echo 
'setlocale(LC_ALL, "en_US", "american", "american english", "american-english", "english-american", "english-us", "english-usa", "enu", "us", "usa"); <br><br>';
echo 
$tz_03 '<br><br>';

$stnow strtotime("now");

$stlat 28.488677;
$stlong = -80.5750074;
// Cape Canaveral, Florida - USA

$arr_sun_info date_sun_info($stnow$stlat$stlong);

echo 
'LATITUDE = ' $stlat '<br>';

echo 
'LONGITUDE = ' $stlong '<br><br>';

$stsrise $arr_sun_info['sunrise'];
$stssrise strftime("%Hh %Mmin %Ss"$stsrise);

$stsset $arr_sun_info['sunset'];
$stssset strftime("%Hh %Mmin %Ss"$stsset);

$ststrns $arr_sun_info['transit'];
$stsstrns strftime("%Hh %Mmin %Ss"$ststrns);

$stctwbeg $arr_sun_info['civil_twilight_begin'];
$stsctwbeg strftime("%Hh %Mmin %Ss"$stctwbeg); 

$stctwend $arr_sun_info['civil_twilight_end'];
$stsctwend strftime("%Hh %Mmin %Ss"$stctwend); 

$stntwbeg $arr_sun_info['nautical_twilight_begin'];
$stsntwbeg strftime("%Hh %Mmin %Ss"$stntwbeg);

$stntwend $arr_sun_info['nautical_twilight_end'];
$stsntwend strftime("%Hh %Mmin %Ss"$stntwend);

$statwbeg $arr_sun_info['astronomical_twilight_begin'];
$stsatwbeg strftime("%Hh %Mmin %Ss"$statwbeg); 

$statwend $arr_sun_info['astronomical_twilight_end'];
$stsatwend strftime("%Hh %Mmin %Ss"$statwend); 

?>
Cape Canaveral, Florida<br>
Today: <?php echo strftime("%A, %d de %B de %Y"time()); ?>
<br><br>
<table width="100%" align="center" border="1" cellpadding="5" cellspacing="5">
<tbody><tr><td>EVENT INDEXES</td><td>TIMESTAMP</td><td>MEANING</td>
<td>TIME OF DAY</td></tr>
<tr><td width="27%">[sunrise]</td>
<td width="13%"><?php echo $stsrise?></td>
<td width="28%">The time of the sunrise</td>
<td><?php echo $stssrise?></td></tr>
<tr><td>[sunset]</td>
<td><?php echo $stsset?></td>
<td>The time of the sunset</td>
<td><?php echo $stssset?></td></tr>
<tr><td>[transit]</td>
<td><?php echo $ststrns?></td>
<td>The time when the sun is at its zenith</td>
<td><?php echo $stsstrns?></td></tr>
<tr><td>[civil_twilight_begin]</td>
<td><?php echo $stctwbeg?></td>
<td>The start of the civil dawn</td>
<td><?php echo $stsctwbeg?></td></tr>
<tr><td>[civil_twilight_end]</td>
<td><?php echo $stctwend?></td>
<td>The end of the civil dusk</td>
<td><?php echo $stsctwend?></td></tr>
<tr><td>[nautical_twilight_begin]</td>
<td><?php echo $stntwbeg?></td>
<td>The start of the nautical dawn</td>
<td><?php echo $stsntwbeg?></td></tr>
<tr><td>[nautical_twilight_end]</td>
<td><?php echo $stntwend?></td>
<td>The end of the nautical dusk</td>
<td><?php echo $stsntwend?></td></tr>
<tr><td>[astronomical_twilight_begin]</td>
<td><?php echo $statwbeg?></td>
<td>The start of the astronomical dawn</td>
<td><?php echo $stsatwbeg?></td></tr>
<tr><td>[astronomical_twilight_end]</td>
<td><?php echo $statwend?></td>
<td>The end of the astronomical dusk</td>
<td><?php echo $stsatwend?></td></tr>
<tr><td colspan="4">ed48</td></tr></tbody></table>