<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.calendar.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.easter-date.php',
    1 => 'easter_date',
    2 => 'Get Unix timestamp for local midnight on Easter of a given year',
  ),
  'up' => 
  array (
    0 => 'ref.calendar.php',
    1 => 'Функції Календаря',
  ),
  'prev' => 
  array (
    0 => 'function.cal-to-jd.php',
    1 => 'cal_to_jd',
  ),
  'next' => 
  array (
    0 => 'function.easter-days.php',
    1 => 'easter_days',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/calendar/functions/easter-date.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.easter-date" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">easter_date</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">easter_date</span> &mdash; <span class="dc-title">Get Unix timestamp for local midnight on Easter of a given year</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.easter-date-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>easter_date</strong></span>(<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.integer.php" class="type int">int</a></span></span> <code class="parameter">$year</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = <strong><code><a href="calendar.constants.php#constant.cal-easter-default">CAL_EASTER_DEFAULT</a></code></strong></span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   Returns the Unix timestamp corresponding to midnight on Easter of
   the given year.
  </p>
  <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">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">year</code></dt>
     <dd>
      <p class="para">
       The year must be a number between 1970 and 2037 for 32-bit systems, or between 1970 and 2,000,000,000 for 64-bit systems.
       If omitted or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, defaults to the current year according to the local time.
      </p>
     </dd>
      
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       Allows Easter dates to be calculated based on the Julian calendar when set
       to <strong><code><a href="calendar.constants.php#constant.cal-easter-always-julian">CAL_EASTER_ALWAYS_JULIAN</a></code></strong>. See also <a href="calendar.constants.php" class="link">calendar constants</a>.
       </p>
     </dd>
      
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.easter-date-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   The easter date as a unix timestamp.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.easter-date-errors">
  <h3 class="title">Помилки/виключення</h3>
  <p class="para">
   A <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> is thrown if the year is earlier than 1970 or later than 2037
   when running on a 32-bit system, or later than 2,000,000,000 on a 64-bit system.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.easter-date-changelog">
  <h3 class="title">Журнал змін</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версія</th>
      <th>Опис</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.3.0</td>
      <td>
       On 64-bit systems, the <code class="parameter">year</code> parameter now accepts values within the range of 1970 to 2,000,000,000.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">year</code> is nullable now.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       A <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> is now thrown when
       <code class="parameter">year</code> is outside the allowed range.
       Previously, an <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> was raised
       and the function returned <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


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

   </div>

   <div class="example" id="example-2">
    <p><strong>Приклад #2 Using <span class="function"><strong>easter_date()</strong></span> with <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$timestamp </span><span style="color: #007700">= </span><span style="color: #0000BB">easter_date</span><span style="color: #007700">(</span><span style="color: #0000BB">2023</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$datetime </span><span style="color: #007700">= new </span><span style="color: #0000BB">\DateTime</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$datetime</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setTimestamp</span><span style="color: #007700">(</span><span style="color: #0000BB">$timestamp</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$datetime</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #DD0000">'M-d-Y'</span><span style="color: #007700">); </span><span style="color: #FF8000">// Apr-09-2023<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">Примітки</h3>
  <blockquote class="note"><p><strong class="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
    <code class="literal">TZ</code> environment variable to determine the time zone it
    should operate in, rather than using PHP&#039;s
    <a href="datetime.configuration.php#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.php" class="function">easter_days()</a></span> with
    <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span> and <span class="classname"><a href="class.dateinterval.php" class="classname">DateInterval</a></span> 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 </span><span style="color: #0000BB">get_easter_datetime</span><span style="color: #007700">(</span><span style="color: #0000BB">$year</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$base </span><span style="color: #007700">= new </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 />    </span><span style="color: #0000BB">$days </span><span style="color: #007700">= </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 />    return </span><span style="color: #0000BB">$base</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">add</span><span style="color: #007700">(new </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 (</span><span style="color: #0000BB">range</span><span style="color: #007700">(</span><span style="color: #0000BB">2012</span><span style="color: #007700">, </span><span style="color: #0000BB">2015</span><span style="color: #007700">) as </span><span style="color: #0000BB">$year</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Easter in %d is on %s\n"</span><span style="color: #007700">,<br />           </span><span style="color: #0000BB">$year</span><span style="color: #007700">,<br />           </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 j'</span><span style="color: #007700">));<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <p class="para">Поданий вище приклад
виведе:</p>
    <div class="example-contents screen">
<div class="notescode"><pre class="notescode">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">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li>
     <span class="function"><a href="function.easter-days.php" 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><?php manual_footer($setup); ?>