All the good things about Easter aside, it’s one of those holidays that’s a pain to get the date for. This is because the date of Easter is based on the lunar cycle and Spring Equinox (March 21st). The date of Easter on a given year could fall between March 22nd and April 25th. Fortunately PHP has us covered with a pair of functions, one to get the number of days after March 21st until Easter Sunday and a second function that gives us the exact date.
If you simply want to know the number of days after March 21st, you can use
easter_days() which takes a single argument for the year you want to know
the number of days for:
Personally, this function doesn’t have much value to me when the counterpart
easter_date() exists. The date function takes the same argument but keep
in mind that it returns the Unix timestamp, so if you want the date you will
need to use the
date() function as well:
Knowing the date of Easter is also good for being able to determine a few other important days like Ash Wednesday, Palm Sunday and Good Friday.
Happy Easter y’all!