easter in php ...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zick
Forum Commoner
Posts: 33
Joined: Thu Aug 14, 2003 3:18 pm

easter in php ...

Post 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 ...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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 :P
zick
Forum Commoner
Posts: 33
Joined: Thu Aug 14, 2003 3:18 pm

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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().
zick
Forum Commoner
Posts: 33
Joined: Thu Aug 14, 2003 3:18 pm

Post by zick »

yeah, i noticed that ...
i'm in the process of converting it right now.

thanks again.
Post Reply