Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 3011

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns an array with information about sunset/sunrise and twilight begin/end</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.date-sub.html">date_sub</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.date-sunrise.html">date_sunrise</a></div>
 <div class="up"><a href="ref.datetime.html">Date/Time Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.date-sun-info" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">date_sun_info</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2, PHP 7)</p><p class="refpurpose"><span class="refname">date_sun_info</span> &mdash; <span class="dc-title">Returns an array with information about sunset/sunrise and twilight begin/end</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.date-sun-info-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>date_sun_info</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$time</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$latitude</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$longitude</code></span>
   )</div>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.date-sun-info-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">time</code></dt>

     <dd>

      <p class="para">
       Timestamp.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">latitude</code></dt>

     <dd>

      <p class="para">
       Latitude in degrees.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">longitude</code></dt>

     <dd>

      <p class="para">
       Longitude in degrees.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.date-sun-info-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns array on success or <strong><code>FALSE</code></strong> on failure.
   The structure of the array is detailed in the following list:
  </p>
  <p class="para">
   <dl>

    
     <dt>
<em>sunrise</em></dt>

     <dd>

      <span class="simpara">
       The time of the sunrise (zenith angle = 90°35&#039;).
      </span>
     </dd>
 
    
    
     <dt>
<em>sunset</em></dt>

     <dd>

      <span class="simpara">
       The time of the sunset (zenith angle = 90°35&#039;).
      </span>
     </dd>
 
    
    
     <dt>
<em>transit</em></dt>

     <dd>

      <span class="simpara">
       The time when the sun is at its zenith, i.e. has reached its topmost
       point.
      </span>
     </dd>
 
    
    
     <dt>
<em>civil_twilight_begin</em></dt>

     <dd>

      <span class="simpara">
       The start of the civil dawn (zenith angle = 96°). It ends at <em>sunrise</em>.
      </span>
     </dd>
 
    
    
     <dt>
<em>civil_twilight_end</em></dt>

     <dd>

      <span class="simpara">
       The end of the civil dusk (zenith angle = 96°). It starts at <em>sunset</em>.
      </span>
     </dd>
 
    
    
     <dt>
<em>nautical_twilight_begin</em></dt>

     <dd>

      <span class="simpara">
       The start of the nautical dawn (zenith angle = 102°). It ends at
       <em>civil_twilight_begin</em>.
      </span>
     </dd>
 
    
    
     <dt>
<em>nautical_twilight_end</em></dt>

     <dd>

      <span class="simpara">
       The end of the nautical dusk (zenith angle = 102°). It starts at
       <em>civil_twilight_end</em>.
      </span>
     </dd>
 
    
    
     <dt>
<em>astronomical_twilight_begin</em></dt>

     <dd>

      <span class="simpara">
       The start of the astronomical dawn (zenith angle = 108°). It ends at
       <em>nautical_twilight_begin</em>.
      </span>
     </dd>
 
    
    
     <dt>
<em>astronomical_twilight_end</em></dt>

     <dd>

      <span class="simpara">
       The end of the astronomical dusk (zenith angle = 108°). It starts at
       <em>nautical_twilight_end</em>.
      </span>
     </dd>
 
    
   </dl>

  </p>
  <p class="para"> 
   The values of the array elements are either UNIX timestamps, <strong><code>FALSE</code></strong> if the
   sun is below the respective zenith for the whole day, or <strong><code>TRUE</code></strong> if the sun is
   above the respective zenith for the whole day.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.date-sun-info-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>5.2.2</td>
      <td>
       The order of <code class="parameter">latitude</code> and
       <code class="parameter">longitude</code> has been swapped.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.date-sun-info-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2794">
    <p><strong>Example #1 A <span class="function"><strong>date_sun_info()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$sun_info&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">date_sun_info</span><span style="color: #007700">(</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"2006-12-12"</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">31.7667</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">35.2333</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">$sun_info&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$key</span><span style="color: #DD0000">:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"H:i:s"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
sunrise: 05:52:11
sunset: 15:41:21
transit: 10:46:46
civil_twilight_begin: 05:24:08
civil_twilight_end: 16:09:24
nautical_twilight_begin: 04:52:25
nautical_twilight_end: 16:41:06
astronomical_twilight_begin: 04:21:32
astronomical_twilight_end: 17:12:00
</pre></div>
    </div>
   </div>
   <div class="example" id="example-2795">
    <p><strong>Example #2 Polar night</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">date_sun_info</span><span style="color: #007700">(</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"2017-12-21"</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">90</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(9) {
  [&quot;sunrise&quot;]=&gt;
  bool(false)
  [&quot;sunset&quot;]=&gt;
  bool(false)
  [&quot;transit&quot;]=&gt;
  int(1513857490)
  [&quot;civil_twilight_begin&quot;]=&gt;
  bool(false)
  [&quot;civil_twilight_end&quot;]=&gt;
  bool(false)
  [&quot;nautical_twilight_begin&quot;]=&gt;
  bool(false)
  [&quot;nautical_twilight_end&quot;]=&gt;
  bool(false)
  [&quot;astronomical_twilight_begin&quot;]=&gt;
  bool(false)
  [&quot;astronomical_twilight_end&quot;]=&gt;
  bool(false)
}
</pre></div>
    </div>
   </div>
   <div class="example" id="example-2796">
    <p><strong>Example #3 Midnight sun</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">date_sun_info</span><span style="color: #007700">(</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"2017-06-21"</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">90</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(9) {
  [&quot;sunrise&quot;]=&gt;
  bool(true)
  [&quot;sunset&quot;]=&gt;
  bool(true)
  [&quot;transit&quot;]=&gt;
  int(1498046510)
  [&quot;civil_twilight_begin&quot;]=&gt;
  bool(true)
  [&quot;civil_twilight_end&quot;]=&gt;
  bool(true)
  [&quot;nautical_twilight_begin&quot;]=&gt;
  bool(true)
  [&quot;nautical_twilight_end&quot;]=&gt;
  bool(true)
  [&quot;astronomical_twilight_begin&quot;]=&gt;
  bool(true)
  [&quot;astronomical_twilight_end&quot;]=&gt;
  bool(true)
}
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.date-sun-info-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.date-sunrise.html" class="function" rel="rdfs-seeAlso">date_sunrise()</a> - Returns time of sunrise for a given day and location</span></li>
    <li class="member"><span class="function"><a href="function.date-sunset.html" class="function" rel="rdfs-seeAlso">date_sunset()</a> - Returns time of sunset for a given day and location</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.date-sub.html">date_sub</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.date-sunrise.html">date_sunrise</a></div>
 <div class="up"><a href="ref.datetime.html">Date/Time Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>