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:
- $year This parameter specifies the year. When no parameter is passed the current year is taken as the default value.
- $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
echo easter_days(), "\n" ;
$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
$year = 2015;
echo easter_days( $year ), "\n" ;
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
$year = 2014;
echo easter_days( $year , CAL_EASTER_ROMAN), "\n" ;
?>
|
Output:
30
Reference: http://php.net/manual/en/function.easter-days.php
Last Updated :
30 Apr, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...