PHP | easter_days() Function

The easter_days() Function is a built-in function in PHP which returns the number of days after March 21, that the Easter Day is in the given year. When no year is given, the current year is taken as the default value.

Syntax:

easter_days( $year, $method )

Parameters: The function accepts two optional parameters as shown above and explained below:

  1. $year This parameter specifies the year. When no parameter is passed the current year is taken as the default value.
  2. $method – This parameter allows you to calculate easter dates based on other calendars. If the $method is set to CAL_EASTER_ROMAN, it uses the Gregorian calendar during the years 1582 – 1752.

Return Value: The function returns the number of days after March 21, that the Easter Day is in the given year. When no $year is passed as an argument the current year is taken as the default year and the number of days after March 21 of the current year is returned.

Examples:

Input :  $year = 2018
Output : 11

Input : $year = 2017
Output : 26  

Input: $year = 2015 $method = CAL_EASTER_ROMAN
Output : 15  

Below programs illustrates the use of easter_days() function:

Program 1: The program below explains the working of easter_days() function when no parameter is passed.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to demonstrate the 
// easter_days() function 
// when no parameter is passed 
  
echo easter_days(), "\n";  
  
// verified by passing current year
$year = 2018; 
echo easter_days($year);  
?>

chevron_right


Output:

11
11

Program 2: The program below explains the working of easter_days() function when $year parameter is passed

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to demonstrate the 
// easter_days() function 
// when $year parameter is passed 
  
  
$year = 2015; 
  
// no of days for Easter after march 21 of year 2015
echo easter_days($year), "\n";  
  
  
// the Easter date of year 2015
echo date("M-d-Y", easter_date($year));     
?>

chevron_right


Output:

15
Apr-05-2015

Program 3: The program below explains the working of easter_days() function when both the parameters is passed.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to demonstrate the 
// easter_days() function 
// when both parameters are passed 
  
  
$year = 2014; 
  
// no of days for Easter after march 21 of year 2014 
// of Gregorian Calendar
echo easter_days($year, CAL_EASTER_ROMAN), "\n";  
?>

chevron_right


Output:

30

Reference: http://php.net/manual/en/function.easter-days.php



My Personal Notes arrow_drop_up

The function of education is to teach one to think intensively and to think critically

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.