I found the following function on the PHP Manual page that calculates the Orthodox Easter date (source: http://www.php.net/manual/en/function.easter-date.php).
function easterOrthodox_date($year) {
$a = $year % 4;
$b = $year % 7;
$c = $year % 19;
$d = (19 * $c + 15) % 30;
$e = (2 * $a + 4 * $b - $d + 34) % 7;
$month = floor(($d + $e + 114) / 31);
$day = (($d + $e + 114) % 31) + 1;
$de = mktime(0, 0, 0, $month, $day + 13, $year);
return $de;
}
I am using the following line to get this date for a certain year (selYear
):
$EasterOrth = date('Y-m-d', easterOrthodox_date($selYear));
When I echo the result on my page this looks correct and shows 2014-04-20 (which is correct as for this year it is the same date as for the catholic Easter).
However, when I use this for other calculations it returns wrong results, e.g. the Dec 31. Is it possible that in this case I need to format this differently in order to get a date with the format yyyy-mm-dd ?
Update: The above variable is being passed to a stored procedure in SQL where I run the following Select (part of a longer query):
SELECT DATEADD(d, daysFromEaster, @EasterOrth) AS dayX,
category1,
category2,
'' AS validity
FROM DayCheck_Easter
WHERE mode = 'EasterOrth'
This should only fetch items from a table where the mode is set to EasterOrth and it seems the issue is with the first line here where I am adding a number of days (int). It works fine in several other Selects but here it calculates the wrong dates which is why I thought my formatting is wrong so that it isnt recognised as date.
Thanks, Mike.