easter_dateRETURNS the
UNIX timestamp for midnight on
EASTER of a given year.
<?php
int easter_date ( int|null $year = null ,
int $mode = CAL_EASTER_DEFAULT )
where,
$year = The year as a integer between 1970 to 2037
$mode = The easter date is calculated according this mode
?>
$year
The year as a integer between 1970 to 2037.
$mode
The easter date is calculated according this mode.
CONSTANT |
VAL |
WHAT DOES |
DEFAULT |
CAL_EASTER_DEFAULT |
0 |
Calculate Easter for years before 1753 according to the Julian calendar, and for later years according to the Gregorian calendar |
CAL_EASTER_DEFAULT |
CAL_EASTER_ROMAN |
1 |
Calculate Easter for years before 1583 according to the Julian calendar, and for later years according to the Gregorian calendar |
CAL_EASTER_ALWAYS_GREGORIAN |
2 |
Calculate Easter according to the proleptic Gregorian calendar |
CAL_EASTER_ALWAYS_JULIAN |
3 |
Calculate Easter according to the Julian calendar |
ed48 |
Sinze PHP 8.0.0 $year is nullable.
The entered $year is between 1970 and 2037.
If $year = null or omitted, the $year assumes the current year according to the localtime.
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.
This function relies on your system's C library time functions, rather than using PHP's internal date and time functions.
As a consequence, easter_date uses the TIMEZONE environment variable to determine the time zone it should operate in, rather than using PHP's default time zone, which may result in unexpected behaviour when using this function in conjunction with other date functions in PHP.
EXERCISE
<?php
date_default_timezone_set('America/Los_Angeles');
$thisyeareaster01 = easter_date();
$dtdftz01 = date_default_timezone_get();
setlocale(LC_ALL, "en_US", "american", "american english", "american-english", "english-american", "english-us", "english-usa", "enu", "us", "usa");
$dteaster01 = strftime('%A, %B %d %Y %Hh %Mmin %Ss', $thisyeareaster01);
echo $dtdftz01 . '<br><br>' . $thisyeareaster01 . ' => ' . $dteaster01;
?>
EXERCISE
<?php
date_default_timezone_set('America/Sao_Paulo');
$thisyeareaster02 = easter_date();
$dtdftz02 = date_default_timezone_get();
setlocale(LC_ALL, "pt_BR.utf-8", "portuguese-brazil", "ptb");
$dteaster02 = strftime('%A, %d de %B de %Y %Hh %Mmin %Ss', $thisyeareaster02);
echo $dtdftz02 . '<br><br>' . $thisyeareaster02 . ' => ' . $dteaster02;
?>
EXERCISE
<?php
date_default_timezone_set('UTC');
$thisyeareaster03 = easter_date();
$dtdftz03 = date_default_timezone_get();
setlocale(LC_ALL, "en_US", "american", "american english", "american-english", "english-american", "english-us", "english-usa", "enu", "us", "usa");
$dteaster03 = strftime('%A, %Y %B %d %Hh %Mmin %Ss', $thisyeareaster03);
echo $dtdftz03 . '<br><br>' . $thisyeareaster03 . ' => ' . $dteaster03;
?>
EXERCISE
<?php
$dtdftz04 = date_default_timezone_get();
$thisyeareaster04 = easter_date();
$dteaster04 = strftime('%A, %Y %B %d %Hh %Mmin %Ss', $thisyeareaster04);
echo $dtdftz04 . '<br><br>' . $thisyeareaster04 . ' => ' . $dteaster04;
?>
EXERCISE
<?php
$dtdftz05 = date_default_timezone_get();
echo $dtdftz05 . '<br><br>';
$y05 = 1970;
// If $y05 < 1970 there will be a Fatal error: ..
$ym05 = 2037;
// If $ym05 > 2037 there will be a Fatal error: ..
for($y05; $y05 <= $ym05; $y05++)
{
$thisyeareaster05 = easter_date($y05);
$dteaster05 = strftime('%A, %Y %B %d %Hh %Mmin %Ss', $thisyeareaster05);
echo '( ' . $y05 . ') ' . $thisyeareaster05 . ' => ' . $dteaster05 . '<br>';
}
?>