PHP Function Reference

PHP easter_days() Function



The PHP easter_days() function returns the number of days after March 21 on which Easter falls for a given year. If no year is specified, the current year is assumed.

Note: This function can be used instead of easter_date() to calculate Easter for years which fall outside the range of Unix timestamps (i.e. before 1970 or after 2037).

Syntax

easter_days(year, mode)

Parameters

year Optional. Specify the year as a positive number. If omitted or null, defaults to the current year according to the local time.
mode Optional. Allows Easter dates to be calculated based on the Gregorian calendar during the years 1582 - 1752 when set to CAL_EASTER_ROMAN. Default is CAL_EASTER_DEFAULT.

Return Value

Returns the number of days after March 21st that the Easter Sunday is in the given year.

Exceptions

NA.

Example:

The example below shows the usage of easter_days() function.

<?php
//no of days for Easter after 
//March 21 for current year
echo easter_days()."\n";
 
//no of days for Easter after 
//March 21 for year 2015
echo easter_days(2015)."\n";

//Easter date for current year
echo date("M-d-Y", easter_date())."\n";
 
//Easter date for year 2015
echo date("M-d-Y", easter_date(2015))."\n";
?>

The output of the above code will be:

14
15
Apr-04-2021
Apr-05-2015

Example:

Consider one more example where mode parameter is used with this function.

<?php
//no of days for Easter after 
//March 21 for year 1632
echo easter_days(1632, CAL_EASTER_ROMAN)."\n";
?>

The output of the above code will be:

21

❮ PHP Calendar Reference