easter_days() returns the number of days after March 21 on which Easter falls.
$daysAfterMarch21 = easter_days(2027);
echo $daysAfterMarch21;<?php
echo easter_days(2021); // Output is 14
echo "<br>";
echo easter_days(2020); // Output is 22
echo "<br>";
echo easter_days(); // Uses the current year
echo "<br>";
echo easter_days(2018); // Output is 11
echo "<br>";
echo easter_days(2017); // Output is 26
echo "<br>";
echo easter_days(2016); // Output is 6
?>
Syntax
easter_days(?int $year = null, int $mode = CAL_EASTER_DEFAULT): int
| Parameter | DESCRIPTION |
|---|---|
| $year | Optional : Year in four digits |
| $method | Optional : CAL_EASTER_DEFAULT ,CAL_EASTER_ROMAN |
easter_date(): gives the timestamp of Easter Date
easter_days() is useful when you want the result in PHP's configured timezone or need years outside the practical Unix-timestamp range of easter_date().
$year = 2027;
$base = new DateTimeImmutable("$year-03-21");
$days = easter_days($year);
$easter = $base->add(new DateInterval("P{$days}D"));
echo $easter->format('Y-m-d');
Information about available Calendars