Forum Moderators: coopster

Message Too Old, No Replies

Is Easter really on a Saturday?

or is there something wrong with easter_date()?

         

neophyte

11:16 am on Mar 22, 2008 (gmt 0)

10+ Year Member



Hello All -

Working on a calendar project which displays various holidays throughout the year. Amoung the tricker ones is of course Easter. Then (thanks be to the Gods) that PHP has a built-in function to find easter sundays based upon the year you feed it.

So I tested it and ... huh? ... it echos that easter sunday for 2008 falls on Saturday, March 22, 2008.

Code Here:

echo 'Easter Sunday, 2008 falls on: ' , date('l, F d, Y', easter_date(2008));

Did I miss the memo where Easters are now on Saturdays, or am I doing something wrong, or is there something wrong with my system or the easter_date() function?

I've corrected the problem by adding a day's worth of seconds - easter_date(2008) + 86400 - but I find this curious (and not a little bit un-nerving).

Does anyone have any insight on what's going on?

Neophyte

Neophyte

PCInk

12:57 pm on Mar 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Easter can fall on any day. The date of Easter is Nisan 14th (Jewish calendar) so it can move on our calendars since we have a different number of days in a year (both are modified by leap days/months which are different for each system).

Easter Sunday is simply the Sunday that is after the actual day of Easter (unless the it falls on a Sunday), so you will have to get easter_date() and then check if it is a Sunday - if not, keep adding a day until it is. So Easter this year is 22nd March, Easter Sunday is 23rd March.

[edited by: PCInk at 12:58 pm (utc) on Mar. 22, 2008]

vincevincevince

1:01 pm on Mar 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The date of Easter Day was defined by the Council of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.

There are comments on that same php.net page for easter_date which indicate that you need to be careful about time zones (try using gmdate() around the easter_date() rather than plain date()). Also; that easter_days() will work.

coopster

2:07 pm on Mar 22, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm running PHP 5.2.5 and configuration directive
date.timezone = UTC
on my local development box and easter_date [php.net] returns the correct date. There is a known bug [bugs.php.net] as mentioned by vincevincevince that you may need to investigate on your particular installation.

neophyte

12:32 am on Mar 23, 2008 (gmt 0)

10+ Year Member



PCInk, Vincevincevince, Coopster -

Thank you all for your replies.

Coopster, I'm running php 5.2. I un-commented date.timezone in my .ini and added "= UTC" but still no dice locally - still reports Saturday. I did, however, put a test page with easter_date(2008) on my live hosting site and there it reports that easter IS on Sunday so I guess my particular problem has something to do with my dev environment. As long as it works on my hosting site, I'm okay.

Thanks again to all.

Neophyte

coopster

1:11 pm on Mar 24, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm running php 5.2. I un-commented date.timezone in my .ini and added "= UTC" but still no dice locally

Don't forget to reboot. And if it is indeed just 5.2, try updating to the latest version as I believe that bug report was for 5.2.1