Page 1 of 1
easter in php ...
Posted: Mon Mar 07, 2005 11:55 am
by zick
wonderring if anyone knows of a script to figure out when easter falls ... i've been trying to write a script for awhile that figures out if today is easter and writes a little "happy easter" message. actually the script is for all holidays, but easter is the toughest of them. most holidays fall on specific days like march 17 is always st.patty's day. easter is a wierd one.
thanx for any feedback ...
Posted: Mon Mar 07, 2005 12:03 pm
by feyd
here's how to figure it out:
http://aa.usno.navy.mil/faq/docs/easter.html
so you just have to figure out when the full moon is after the vernal equinox. Simple enough

Posted: Mon Mar 07, 2005 6:26 pm
by zick
Code: Select all
c = y / 100
n = y - 19 * ( y / 19 )
k = ( c - 17 ) / 25
i = c - c / 4 - ( c - k ) / 3 + 19 * n + 15
i = i - 30 * ( i / 30 )
i = i - ( i / 28 ) * ( 1 - ( i / 28 ) * ( 29 / ( i + 1 ) ) * ( ( 21 - n ) / 11 ) )
j = y + y / 4 + i + 2 - c + c / 4
j = j - 7 * ( j / 7 )
l = i - j
m = 3 + ( l + 40 ) / 44
d = l + 28 - 31 * ( m / 4 )
okay, cool ... looks like i got a script i can work with.
they say that "y" is the year, "m" is the month, and "d" is the day. do you have any idea what the other variables represent or are they just temporary letters. i want to give them more "friendly" variable names so they don't get confused with other variables.
thanks.
Posted: Mon Mar 07, 2005 6:58 pm
by feyd
k, i, j, and l are all temporary variables, it appears. Not sure what n is.
Please note, when converting this to php, this code is using integer math. Meaning it won't generate decimals when computed. PHP doesn't have such a system, so you will need to use things like floor().
Posted: Mon Mar 07, 2005 9:55 pm
by zick
yeah, i noticed that ...
i'm in the process of converting it right now.
thanks again.