<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.datetime.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.date-sunset.php',
    1 => 'date_sunset',
    2 => 'Returns time of sunset for a given day and location',
  ),
  'up' => 
  array (
    0 => 'ref.datetime.php',
    1 => 'Date/Time Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.date-sunrise.php',
    1 => 'date_sunrise',
  ),
  'next' => 
  array (
    0 => 'function.date-time-set.php',
    1 => 'date_time_set',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/datetime/functions/date-sunset.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.date-sunset" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">date_sunset</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</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 id="function.date-sunset-refsynopsisdiv">
  <div class="warning"><strong class="warning">Avviso</strong>
   <p class="para">
    This function has been <em>DEPRECATED</em> as of PHP 8.1.0.
    Relying on this function is highly discouraged. Use
    <span class="function"><a href="function.date-sun-info.php" class="function">date_sun_info()</a></span> instead.
   </p>
  </div>
 </div>

 <div class="refsect1 description" id="refsect1-function.date-sunset-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="attribute"><a href="class.deprecated.php">#[\Deprecated]</a> </span><br>
   <span class="methodname"><strong>date_sunset</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$timestamp</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$returnFormat</code><span class="initializer"> = <strong><code><a href="datetime.constants.php#constant.sunfuncs-ret-string">SUNFUNCS_RET_STRING</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.float.php" class="type float">float</a></span></span> <code class="parameter">$latitude</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.float.php" class="type float">float</a></span></span> <code class="parameter">$longitude</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.float.php" class="type float">float</a></span></span> <code class="parameter">$zenith</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.float.php" class="type float">float</a></span></span> <code class="parameter">$utcOffset</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.float.php" class="type float">float</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></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">Elenco dei parametri</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">returnFormat</code></dt>
     <dd>
      <p class="para">
       <table class="doctable table">
        <caption><strong><code class="parameter">returnFormat</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.php" 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.php" 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.php" class="type int">int</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.php#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.php#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.php#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">utcOffset</code></dt>
     <dd>
      <p class="para">
       Specified in hours.
       The <code class="parameter">utcOffset</code> is ignored, if
       <code class="parameter">returnFormat</code> is
       <strong><code><a href="datetime.constants.php#constant.sunfuncs-ret-timestamp">SUNFUNCS_RET_TIMESTAMP</a></code></strong>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.date-sunset-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Returns the sunset time in a specified <code class="parameter">returnFormat</code> on
   success o <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> in caso di fallimento. 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 errors" id="refsect1-function.date-sunset-errors">
  <h3 class="title">Errori/Eccezioni</h3>
   
   <p class="para">
Ogni chiamata a una funzione data/ora genera un <strong><code><a href="errorfunc.constants.php#constant.e-notice">E_NOTICE</a></code></strong> 
se il time zone non è valido, e/o un messaggio <strong><code><a href="errorfunc.constants.php#constant.e-strict">E_STRICT</a></code></strong>
o <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>
se si usano le impostazioni di sistema o la variabile d&#039;ambiente <var class="varname">TZ</var>.
Vedere anche <span class="function"><a href="function.date-default-timezone-set.php" class="function">date_default_timezone_set()</a></span></p>
 
 </div>

 
 <div class="refsect1 changelog" id="refsect1-function.date-sunset-changelog">
  <h3 class="title">Log delle modifiche</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Versione</th>
       <th>Descrizione</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.1.0</td>
       <td>
        This function has been deprecated in favor of <span class="function"><a href="function.date-sun-info.php" class="function">date_sun_info()</a></span>.
       </td>
      </tr>

      <tr>
       <td>8.0.0</td>
       <td>
        <code class="parameter">latitude</code>, <code class="parameter">longitude</code>,
        <code class="parameter">zenith</code> and <code class="parameter">utcOffset</code> are nullable now.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.date-sunset-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>date_sunset()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/* calculate the sunset time for Lisbon, Portugal<br />Latitude: 38.4 North<br />Longitude: 9 West<br />Zenith ~= 90<br />offset: +1 GMT<br />*/<br /><br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"D M d Y"</span><span style="color: #007700">). </span><span style="color: #DD0000">', sunset time : ' </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">(), </span><span style="color: #0000BB">SUNFUNCS_RET_STRING</span><span style="color: #007700">, </span><span style="color: #0000BB">38.4</span><span style="color: #007700">, -</span><span style="color: #0000BB">9</span><span style="color: #007700">, </span><span style="color: #0000BB">90</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);</span></span></code></div>
    </div>

    <div class="example-contents"><p>Il precedente esempio visualizzerà
qualcosa simile a:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in script on line 10
Deprecated: Function date_sunset() is deprecated since 8.1, use date_sun_info() instead in script on line 10
Mon Dec 20 2004, sunset time : 18:13</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>Example #2 No sunset</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$solstice </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">);<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">, </span><span style="color: #0000BB">SUNFUNCS_RET_STRING</span><span style="color: #007700">, </span><span style="color: #0000BB">69.245833</span><span style="color: #007700">, -</span><span style="color: #0000BB">53.537222</span><span style="color: #007700">));</span></span></code></div>
    </div>

    <div class="example-contents"><p>Il precedente esempio visualizzerà:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in script on line 3
Deprecated: Function date_sunset() is deprecated since 8.1, use date_sun_info() instead in script on line 3
bool(false)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.date-sunset-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.date-sun-info.php" 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><?php manual_footer($setup); ?>