Detect Easter Holidays In PHP

Use the following code to detect one week before and after easter.

// Create a DateTimeImmutable object with the current da
$easterDate = (new DateTimeImmutable())->setTimestamp(easter_date());
if (time() > $easterDate->modify('-1 week')->getTimestamp() && time() < $easterDate->modify('+1 week')->getTimestamp()) {
  print 'easter';
else {
  echo 'not easter';

The easter_date() function is key to calculating the date of easter here. If we call the function without passing any parameters then it returns easter for the current year.

Add new comment

The content of this field is kept private and will not be shown publicly.
1 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.