easter_days() : calculates the number of days after March 21 for Easter in a given year

<?Php
echo easter_days(2021); // Output is 14
echo "<br>";
echo easter_days(2020); // Output is 22
echo "<br>";
echo easter_days(); // Output is 31 , default year 2019
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
int easter_days ([ int $year = date("Y") [, int $method = CAL_EASTER_DEFAULT ]] )
ParameterDESCRIPTION
$yearOptional : Year in four digits
$methodOptional : CAL_EASTER_DEFAULT ,CAL_EASTER_ROMAN
Output is in number of days after 21st March the Easter Sunday is in given year ( default is current year )

Examples

easter_date(): gives the timestamp of Easter Date

Find out Easter Date without using easter_date() function

$y=date('Y');// default year
$date = new DateTime("$y-03-21"); // date format for 21st March of current year
$d= easter_days(); // Output is 31 , default year 2019
$date->add(new DateInterval("P".$d."D")); // Add number of days to easter to date format
echo $date->format('Y-M-d'); // Easter date of current year
Output is here
 Easter date for year 2025 is 2025-Apr-20
We created date object for 21st of March of current year. The function easter_days() give number of days between 21st March and Easter day. Then used DateInterval to add number days to Easter to it.
Information about available Calendars
Calendar Functions
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer