PHP easter_date() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Calendar

Definition

In PHP, easter_date() returns the Unix timestamp for midnight on Easter Sunday of a given year.

Easter moves around every year, so it cannot be hard coded. easter_date() works out the date for you, and you can pass the timestamp to date() or strtotime() to show the date or find related holidays such as Good Friday. If you leave out the year, PHP uses the current year.

Syntax

Call easter_date() with the values you need. Start with this line.

PHP
$timestamp = easter_date(2024);
CallWhat it does
easter_date(2024)Returns the timestamp for Easter Sunday 2024, which is March 31.
date('Y-m-d', easter_date(2025))Returns 2025-04-20 as readable text.
easter_date()Returns the timestamp for Easter in the current year.

Use date() to turn the timestamp into text, and strtotime() with a relative string like '-2 days' to get Good Friday. If you only need the number of days after March 21, use easter_days() instead.

Library declarations
PHP
easter_date(?int $year = null, int $mode = CAL_EASTER_DEFAULT): int

Parameters

ParameterDescription
yearOptional. The year as a four digit number. If it is null or omitted, the current year is used. The year must be 1970 or later.
modeOptional. The calendar rule used for the calculation: CAL_EASTER_DEFAULT, CAL_EASTER_ROMAN, CAL_EASTER_ALWAYS_GREGORIAN or CAL_EASTER_ALWAYS_JULIAN. The default is CAL_EASTER_DEFAULT.

Return Value

Return ValueDescription
intThe Unix timestamp for midnight on Easter Sunday, using the server's local time zone. A year that is out of range throws a ValueError.

PHP Examples

Example 1 — Find Easter Sunday

Pass a fixed year and format the returned timestamp with date().

PHP
<?php
date_default_timezone_set('UTC');

$easter = easter_date(2024);

echo date('Y-m-d', $easter), PHP_EOL;
echo date('l', $easter), PHP_EOL;
echo date('Y-m-d', easter_date(2025)), PHP_EOL;

How It Works

  1. date_default_timezone_set() makes sure date() uses a known time zone.
  2. easter_date(2024) returns a Unix timestamp for midnight on Easter Sunday.
  3. date('Y-m-d') turns it into 2024-03-31, and date('l') confirms it is a Sunday.
  4. In 2025 Easter falls later, on April 20.

Example 2 — Leap Years and Out-of-Range Years

Easter works fine in a leap year like 2000, but years before 1970 are not supported and throw an error.

PHP
<?php
date_default_timezone_set('UTC');

echo date('Y-m-d', easter_date(2000)), PHP_EOL;

try {
    easter_date(1969);
} catch (ValueError $e) {
    echo 'Year is out of range', PHP_EOL;
}

echo date('Y-m-d', easter_date(2008)), PHP_EOL;

How It Works

  1. The year 2000 is a leap year, and Easter fell on April 23.
  2. The year 1969 is before the Unix epoch starts in 1970, so PHP throws a ValueError.
  3. The catch block prints a short message instead of crashing.
  4. In 2008 Easter was very early, on March 23.

Example 3 — Holidays Based on Easter

Many holidays are counted from Easter. Add or subtract days with strtotime() to find them.

PHP
<?php
date_default_timezone_set('UTC');

$easter = easter_date(2024);

echo 'Good Friday: ', date('Y-m-d', strtotime('-2 days', $easter)), PHP_EOL;
echo 'Easter Monday: ', date('Y-m-d', strtotime('+1 day', $easter)), PHP_EOL;
echo 'Ascension Day: ', date('Y-m-d', strtotime('+39 days', $easter)), PHP_EOL;
echo 'Pentecost: ', date('Y-m-d', strtotime('+49 days', $easter)), PHP_EOL;

How It Works

  1. We call easter_date(2024) once and reuse the timestamp.
  2. Good Friday is two days before Easter Sunday, and Easter Monday is one day after.
  3. Ascension Day is 39 days after Easter, and Pentecost is 49 days after.
  4. strtotime() accepts a relative text and a base timestamp, so the math stays simple.

Frequently Asked Questions

It returns a Unix timestamp for midnight on Easter Sunday of the year you give. Use date() to turn it into a readable date.
easter_date() gives a full timestamp. easter_days() gives only the number of days after March 21. easter_days() is useful when you want to build the date yourself or work with years outside the timestamp range.
The function returns a Unix timestamp, and timestamps start in 1970. Years before 1970 are not allowed, and very large years may also be rejected depending on your PHP version.
The default mode follows the Western church Easter and uses the Gregorian rules for modern years. Use CAL_EASTER_ALWAYS_JULIAN if you need the Julian calculation.
Yes, it is part of the calendar extension. If PHP says the function is undefined, enable extension=calendar in php.ini or install the php-calendar package.

Next: easter_days()

easter_days() returns the number of days between March 21 and Easter Sunday for a given ye.

easter_days() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful