<!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)</p><p class="refpurpose"><span class="refname">date_sunset</span> — <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("date.default_latitude")</span></span> [, <span class="methodparam"><span class="type">float</span> <code class="parameter">$longitude</code><span class="initializer"> = ini_get("date.default_longitude")</span></span> [, <span class="methodparam"><span class="type">float</span> <code class="parameter">$zenith</code><span class="initializer"> = ini_get("date.sunset_zenith")</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 <em><code class="parameter">timestamp</code></em>) and location. </p> </div> <div class="refsect1 parameters" id="refsect1-function.date-sunset-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">timestamp</code></em></span> <dd> <p class="para"> The <em><code class="parameter">timestamp</code></em> of the day from which the sunset time is taken. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">format</code></em></span> <dd> <p class="para"> <table class="doctable table"> <caption><strong><em><code class="parameter">format</code></em> 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> <dt> <span class="term"><em><code class="parameter">latitude</code></em></span> <dd> <p class="para"> Defaults to North, pass in a negative value for South. See also: <em>date.default_latitude</em> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">longitude</code></em></span> <dd> <p class="para"> Defaults to East, pass in a negative value for West. See also: <em>date.default_longitude</em> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">zenith</code></em></span> <dd> <p class="para"> Default: <em>date.sunset_zenith</em> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">gmtoffset</code></em></span> <dd> <p class="para"> Specified in hours. </p> </dd> </dt> </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 <em><code class="parameter">format</code></em> on success or <strong><code>FALSE</code></strong> on failure. </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-2300"> <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"><?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">);<br /><br /></span><span style="color: #0000BB">?></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> </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> </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>