|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68909 function easter_date() not correct 1970-1989 years
Submitted: 2015-01-25 10:32 UTC Modified: 2020-01-14 18:46 UTC
From: andris dot petrams at gmail dot com Assigned:
Status: No Feedback Package: Calendar related
PHP Version: Irrelevant OS: any
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-01-25 10:32 UTC] andris dot petrams at gmail dot com
From manual page:
easter_date(1970); return Mar-28-1970 (Saturday) is not Easter Day

Test script:
<?php echo date("M-d-Y (l)", easter_date(1970)); ?>

Actual result:
easter_date(); 1970-1989 return:
Apr-10-1971 (Saturday)
Apr-01-1972 (Saturday)
Apr-21-1973 (Saturday)
Apr-13-1974 (Saturday)
Mar-29-1975 (Saturday)
Apr-17-1976 (Saturday)
Apr-09-1977 (Saturday)
Mar-25-1978 (Saturday)
Apr-14-1979 (Saturday)
Apr-05-1980 (Saturday)
Apr-18-1981 (Saturday)
Apr-10-1982 (Saturday)
Apr-02-1983 (Saturday)
Apr-21-1984 (Saturday)
Apr-06-1985 (Saturday)
Mar-29-1986 (Saturday)
Apr-18-1987 (Saturday)
Apr-02-1988 (Saturday)
Mar-25-1989 (Saturday)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-25 11:47 UTC]
-Status: Open +Status: Feedback
 [2015-01-25 11:47 UTC]
There is a Note towards the end of documentation for easter_date(). What happens when you try the sample code it provides?
 [2015-01-25 12:30 UTC] andris dot petrams at gmail dot com
-Status: Feedback +Status: Open
 [2015-01-25 12:30 UTC] andris dot petrams at gmail dot com
My solve for this:

function EasterDate($X){	// X = year to compute
		$K  = floor($X / 100);									// Secular number
		$M  = ceil(15 + (3 * $K + 3) / 4 - (8 * $K + 13) / 25);	// Secular Moon shift
		$S  = ceil(2 - (3 * $K + 3) / 4);						// Secular sun shift
		$A  = $X % 19;											// Moon parameter
		$D  = (19 * $A + $M) % 30;								// Seed for 1st full Moon in spring
		$R  = floor($D / 29 + ($D / 28 - $D / 29) * ($A / 11));	// Calendarian correction quantity
		$OG = 21 + $D - $R;										// Easter limit
		$SZ = 7 - floor($X + $X / 4 + $S) % 7;					// 1st sunday in March
		$OE = 7 - ($OG - $SZ) % 7;								// Distance Easter sunday from Easter limit in days
		$dt = (((($OG + $OE)%31)==0)?31:(($OG + $OE)%31));
		$mn = ((($OG + $OE)>31)?4:3);
		return new DateTime($X."-".$mn."-".$dt);
		//return $date->format('c (l) e');
	return $str;
echo '<table border="1">';
for($i=1970; $i<2038; $i++){
	echo '<tr><td>'.date("c (l) e", easter_date($i)).'</td>
				<td>'.EasterDate($i)->format('c (l) e').'</td></tr>'; }
echo '<table>';

 [2015-01-25 12:41 UTC]
-Status: Open +Status: Feedback
 [2015-01-25 12:41 UTC]
Okay, you decided to do the calculations yourself, that's fine. If you're still interested in resolving your original problem then feel free to answer my earlier question.
 [2015-01-25 12:44 UTC] andris dot petrams at gmail dot com
-Status: Feedback +Status: Open
 [2015-01-25 12:44 UTC] andris dot petrams at gmail dot com
easter_date(): 1970-03-28T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1970-03-29T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1971-04-10T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1971-04-11T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1972-04-01T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1972-04-02T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1973-04-21T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1973-04-22T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1974-04-13T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1974-04-14T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1975-03-29T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1975-03-30T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1976-04-17T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1976-04-18T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1977-04-09T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1977-04-10T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1978-03-25T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1978-03-26T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1979-04-14T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1979-04-15T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1980-04-05T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1980-04-06T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1981-04-18T23:00:00+03:00 (Saturday) Europe/Helsinki
	My Function: 1981-04-19T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1982-04-10T23:00:00+03:00 (Saturday) Europe/Helsinki
	My Function: 1982-04-11T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1983-04-02T23:00:00+03:00 (Saturday) Europe/Helsinki
	My Function: 1983-04-03T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1984-04-21T23:00:00+03:00 (Saturday) Europe/Helsinki
	My Function: 1984-04-22T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1985-04-06T23:00:00+03:00 (Saturday) Europe/Helsinki
	My Function: 1985-04-07T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1986-03-29T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1986-03-30T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1987-04-18T23:00:00+03:00 (Saturday) Europe/Helsinki
	My Function: 1987-04-19T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1988-04-02T23:00:00+03:00 (Saturday) Europe/Helsinki
	My Function: 1988-04-03T00:00:00+03:00 (Sunday) Europe/Helsinki
easter_date(): 1989-03-25T23:00:00+02:00 (Saturday) Europe/Helsinki
	My Function: 1989-03-26T00:00:00+02:00 (Sunday) Europe/Helsinki
easter_date(): 1990-04-15T00:00:00+03:00 (Sunday) Europe/Helsinki
	My Function: 1990-04-15T00:00:00+03:00 (Sunday) Europe/Helsinki
 [2015-01-25 22:52 UTC]
-Status: Open +Status: No Feedback
 [2020-01-14 10:52 UTC] rui at bitpt dot com
Same for all years. PHP 7.2, 7.3 and 7.4
 [2020-01-14 18:46 UTC]
Same questions for you @rui: did you see the note in the documentation, and does the code in it give the expected output?
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Feb 06 05:03:41 2023 UTC