Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 2674

php-manual-en-5.5.7-1.mga4.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>Get Unix timestamp for midnight on Easter of a given year</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.cal-to-jd.html">cal_to_jd</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.easter-days.html">easter_days</a></div>
 <div class="up"><a href="ref.calendar.html">Calendar Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.easter-date" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">easter_date</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">easter_date</span> &mdash; <span class="dc-title">Get Unix timestamp for midnight on Easter of a given year</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.easter-date-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>easter_date</strong></span>
    ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$year</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   Returns the Unix timestamp corresponding to midnight on Easter of
   the given year.
  </p>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    This function will generate a warning if the year is outside
    of the range for Unix timestamps (i.e. before 1970 or after 2037).
   </p>
  </div>
  <p class="para">
   The date of Easter Day was defined by the Council of Nicaea in
   AD325 as the Sunday after the first full moon which falls on or
   after the Spring Equinox.  The Equinox is assumed to always fall
   on 21st March, so the calculation reduces to determining the date
   of the full moon and the date of the following Sunday.  The
   algorithm used here was introduced around the year 532 by
   Dionysius Exiguus.  Under the Julian Calendar (for years before
   1753) a simple 19-year cycle is used to track the phases of the
   Moon.  Under the Gregorian Calendar (for years after 1753 -
   devised by Clavius and Lilius, and introduced by Pope Gregory
   XIII in October 1582, and into Britain and its then colonies in
   September 1752) two correction factors are added to make the
   cycle more accurate.
  </p>
 </div>


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

    <dt>

     <span class="term"><em><code class="parameter">year</code></em></span>
     <dd>

      <p class="para">
       The year as a number between 1970 an 2037
      </p>
     </dd>

    </dt>
  
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.easter-date-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The easter date as a unix timestamp.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.easter-date-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>4.3.0</td>
       <td>
        The <em><code class="parameter">year</code></em> parameter is optional and defaults
        to the current year according to the local time if omitted.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.easter-date-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2246">
    <p><strong>Example #1  <span class="function"><strong>easter_date()</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: #007700">echo&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"M-d-Y"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">easter_date</span><span style="color: #007700">(</span><span style="color: #0000BB">1999</span><span style="color: #007700">));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Apr-04-1999<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"M-d-Y"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">easter_date</span><span style="color: #007700">(</span><span style="color: #0000BB">2000</span><span style="color: #007700">));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Apr-23-2000<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"M-d-Y"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">easter_date</span><span style="color: #007700">(</span><span style="color: #0000BB">2001</span><span style="color: #007700">));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Apr-15-2001<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.easter-date-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
     <span class="function"><strong>easter_date()</strong></span> relies on your system&#039;s C library time
    functions, rather than using PHP&#039;s internal date and time functions. As a
    consequence,  <span class="function"><strong>easter_date()</strong></span> uses the
    <em>TZ</em> environment variable to determine the time zone it
    should operate in, rather than using PHP&#039;s
    <a href="datetime.configuration.html#ini.date.timezone" class="link">default time zone</a>, which may
    result in unexpected behaviour when using this function in conjunction
    with other date functions in PHP.
   </p>
   <p class="para">
    As a workaround, you can use the  <span class="function"><a href="function.easter-days.html" class="function">easter_days()</a></span> with
    <a href="class.datetime.html" class="classname">DateTime</a> and <a href="class.dateinterval.html" class="classname">DateInterval</a> to
    calculate the start of Easter in your PHP time zone as follows:
   </p>
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">get_easter_datetime</span><span style="color: #007700">(</span><span style="color: #0000BB">$year</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$base&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DateTime</span><span style="color: #007700">(</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$year</span><span style="color: #DD0000">-03-21"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$days&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">easter_days</span><span style="color: #007700">(</span><span style="color: #0000BB">$year</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$base</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">add</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">DateInterval</span><span style="color: #007700">(</span><span style="color: #DD0000">"P</span><span style="color: #007700">{</span><span style="color: #0000BB">$days</span><span style="color: #007700">}</span><span style="color: #DD0000">D"</span><span style="color: #007700">));<br />}<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">range</span><span style="color: #007700">(</span><span style="color: #0000BB">2012</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2015</span><span style="color: #007700">)&nbsp;as&nbsp;</span><span style="color: #0000BB">$year</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Easter&nbsp;in&nbsp;%d&nbsp;is&nbsp;on&nbsp;%s\n"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$year</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">get_easter_datetime</span><span style="color: #007700">(</span><span style="color: #0000BB">$year</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #DD0000">'F&nbsp;j'</span><span style="color: #007700">));<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <p class="para">The above example will output:</p>
    <div class="example-contents screen">
<div class="cdata"><pre>
Easter in 2012 is on April 8
Easter in 2013 is on March 31
Easter in 2014 is on April 20
Easter in 2015 is on April 5
</pre></div>
    </div>
   </div>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.easter-date-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member">
      <span class="function"><a href="function.easter-days.html" class="function" rel="rdfs-seeAlso">easter_days()</a> - Get number of days after March 21 on which Easter falls for a given year</span> for calculating Easter 
     before 1970 or after 2037
    </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.cal-to-jd.html">cal_to_jd</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.easter-days.html">easter_days</a></div>
 <div class="up"><a href="ref.calendar.html">Calendar Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>