Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 3013

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 time of sunset for a given day and location</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.date-sunrise.html">date_sunrise</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.date-time-set.html">date_time_set</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-sunset" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">date_sunset</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">date_sunset</span> &mdash; <span class="dc-title">
   Returns time of sunset for a given day and location
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.date-sunset-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>date_sunset</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$timestamp</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$format</code><span class="initializer"> = SUNFUNCS_RET_STRING</span></span>
   [, <span class="methodparam"><span class="type">float</span> <code class="parameter">$latitude</code><span class="initializer"> = ini_get(&quot;date.default_latitude&quot;)</span></span>
   [, <span class="methodparam"><span class="type">float</span> <code class="parameter">$longitude</code><span class="initializer"> = ini_get(&quot;date.default_longitude&quot;)</span></span>
   [, <span class="methodparam"><span class="type">float</span> <code class="parameter">$zenith</code><span class="initializer"> = ini_get(&quot;date.sunset_zenith&quot;)</span></span>
   [, <span class="methodparam"><span class="type">float</span> <code class="parameter">$gmt_offset</code><span class="initializer"> = 0</span></span>
   ]]]]] )</div>

   <p class="para rdfs-comment">
    <span class="function"><strong>date_sunset()</strong></span> returns the sunset time for a given
    day (specified as a <code class="parameter">timestamp</code>) and location.
   </p>
  </div>


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

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

     <dd>

      <p class="para">
       The <code class="parameter">timestamp</code> of the day from which the sunset
       time is taken.
      </p>
     </dd>

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

     <dd>

      <p class="para">
       <table class="doctable table">
        <caption><strong><code class="parameter">format</code> constants</strong></caption>
        
         <thead>
          <tr>
           <th>constant</th>
           <th>description</th>
           <th>example</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>SUNFUNCS_RET_STRING</td>
           <td>returns the result as <span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
           <td>16:46</td>
          </tr>

          <tr>
           <td>SUNFUNCS_RET_DOUBLE</td>
           <td>returns the result as <span class="type"><a href="language.types.float.html" class="type float">float</a></span></td>
           <td>16.78243132</td>
          </tr>

          <tr>
           <td>SUNFUNCS_RET_TIMESTAMP</td>
           <td>returns the result as <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> (timestamp)</td>
           <td>1095034606</td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

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

     <dd>

      <p class="para">
       Defaults to North, pass in a negative value for South.
       See also: <a href="datetime.configuration.html#ini.date.default-latitude" class="link">date.default_latitude</a>
      </p>
     </dd>

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

     <dd>

      <p class="para">
       Defaults to East, pass in a negative value for West.
       See also: <a href="datetime.configuration.html#ini.date.default-longitude" class="link">date.default_longitude</a>
      </p>
     </dd>

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

     <dd>

      <p class="para">
       <code class="parameter">zenith</code> is the angle between the center of the sun
       and a line perpendicular to earth&#039;s surface. It defaults to
       <a href="datetime.configuration.html#ini.date.sunset-zenith" class="link">date.sunset_zenith</a>
       <table class="doctable table">
        <caption><strong>Common <code class="parameter">zenith</code> angles</strong></caption>
        
         <thead>
          <tr>
           <th>Angle</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>90°50&#039;</td>
           <td>Sunset: the point where the sun becomes invisible.</td>
          </tr>

          <tr>
           <td>96°</td>
           <td>Civil twilight: conventionally used to signify the end of dusk.</td>
          </tr>

          <tr>
           <td>102°</td>
           <td>Nautical twilight: the point at which the horizon ends being visible at sea.</td>
          </tr>

          <tr>
           <td>108°</td>
           <td>Astronomical twilight: the point at which the sun ends being the source of any illumination.</td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

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

     <dd>

      <p class="para">
       Specified in hours.
       The <code class="parameter">gmtoffset</code> is ignored, if
       <code class="parameter">format</code> is
       <strong><code>SUNFUNCS_RET_TIMESTAMP</code></strong>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.date-sunset-errors">
  <h3 class="title">Errors/Exceptions</h3>
   
   <p class="para">
Every call to a date/time function will generate a <strong><code>E_NOTICE</code></strong>
if the time zone is not valid, and/or a <strong><code>E_STRICT</code></strong>
or <strong><code>E_WARNING</code></strong> message
if using the system settings or the <var class="varname"><var class="varname">TZ</var></var> environment
variable. See also <span class="function"><a href="function.date-default-timezone-set.html" class="function">date_default_timezone_set()</a></span></p>
 
 </div>


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

     </thead>

     <tbody class="tbody">
      
      <tr><td>5.1.0</td><td><p class="para">
Now issues the <strong><code>E_STRICT</code></strong> and <strong><code>E_NOTICE</code></strong>
time zone errors.</p></td></tr>

     
     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.date-sunset-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the sunset time in a specified <code class="parameter">format</code> on
   success or <strong><code>FALSE</code></strong> on failure. One potential reason for failure is that the
   sun does not set at all, which happens inside the polar circles for part of
   the year.
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.date-sunset-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2799">
    <p><strong>Example #1 <span class="function"><strong>date_sunset()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*&nbsp;calculate&nbsp;the&nbsp;sunset&nbsp;time&nbsp;for&nbsp;Lisbon,&nbsp;Portugal<br />Latitude:&nbsp;38.4&nbsp;North<br />Longitude:&nbsp;9&nbsp;West<br />Zenith&nbsp;~=&nbsp;90<br />offset:&nbsp;+1&nbsp;GMT<br />*/<br /><br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"D&nbsp;M&nbsp;d&nbsp;Y"</span><span style="color: #007700">).&nbsp;</span><span style="color: #DD0000">',&nbsp;sunset&nbsp;time&nbsp;:&nbsp;'&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">date_sunset</span><span style="color: #007700">(</span><span style="color: #0000BB">time</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">SUNFUNCS_RET_STRING</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">38.4</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">9</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">90</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</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
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Mon Dec 20 2004, sunset time : 18:13
</pre></div>
    </div>
   </div>
   <div class="example" id="example-2800">
    <p><strong>Example #2 No sunset</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$solstice&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">'2017-12-21'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">date_sunset</span><span style="color: #007700">(</span><span style="color: #0000BB">$solstice</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SUNFUNCS_RET_STRING</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">69.245833</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">53.537222</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>
bool(false)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.date-sunset-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-sun-info.html" class="function" rel="rdfs-seeAlso">date_sun_info()</a> - Returns an array with information about sunset/sunrise and twilight begin/end</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-sunrise.html">date_sunrise</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.date-time-set.html">date_time_set</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>