Friday, December 12, 2025
HomeLanguagesPHP | easter_days() Function

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.




<?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);  
?>


Output:

11
11

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




<?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));     
?>


Output:

15
Apr-05-2015

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




<?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";  
?>


Output:

30

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

RELATED ARTICLES

Most Popular

Dominic
32444 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6813 POSTS0 COMMENTS
Nicole Veronica
11951 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12027 POSTS0 COMMENTS
Shaida Kate Naidoo
6945 POSTS0 COMMENTS
Ted Musemwa
7198 POSTS0 COMMENTS
Thapelo Manthata
6892 POSTS0 COMMENTS
Umr Jansen
6881 POSTS0 COMMENTS