PHP Tutorial - PHP easter_days() Function






Definition

The easter_days() function returns the number of days between March 21 and the Easter Day for a given year.

Easter Day is the Sunday after the first full moon which falls on or after the Spring Equinox (21st March).

Syntax

PHP easter_days() Function has the following syntax.

easter_days(year,method);

Parameter

ParameterIs RequiredDescription
yearOptional.Selected a year. Default is the current year, local time.
methodOptional.Calculate easter dates based on other calendars.




Return

PHP easter_days() Function returns the number of days between March 21 and the Easter Day for a given year.

Example

Print the number of days after March 21, that the Easter Day is/was for different years:


<?php
echo "Easter Day is ". easter_days() . " days after March 21 this year.\n";
echo "Easter Day was ". easter_days(2011) . " days after March 21 in 2011.\n";
echo "Easter Day was ". easter_days(2012) . " days after March 21 in 2012.\n";
echo "Easter Day will be ". easter_days(2013) . " days after March 21 in 2013.";
?>

The code above generates the following result.