downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

easter_days> <cal_to_jd
[edit] Last updated: Fri, 10 Feb 2012

view this page in

easter_date

(PHP 4, PHP 5)

easter_dateRetourne un timestamp UNIX pour Pâques, à minuit pour une année donnée

Description

int easter_date ([ int $year ] )

Retourne un timestamp UNIX pour Pâques, à minuit, pour une année donnée.

Avertissement

Cette fonction génère une alerte si la date tombe hors de la zone de validité des timestamp UNIX (i.e. avant 1970 ou après 2037).

La date de Pâques a été fixée par le concile de Nicée, en 325 de notre ère, comme étant le dimanche après la première pleine lune qui suit l'équinoxe de printemps. L'équinoxe de printemps est considéré comme étant toujours le 21 mars, ce qui réduit le problème au calcul de la date de la lune pleine qui suit, et le dimanche suivant. L'algorithme fut introduit vers 532, par Dionysius Exiguus. Avec le calendrier Julien, (pour les années avant 1753), un cycle de 19 ans suffit pour connaître les dates des phases de la lune. Avec le calendrier grégorien, (à partir des années 1753, conçu par Clavius et Lilius, puis introduit par le pape Grégoire XIII en octobre 1582, et en Grande Bretagne et ses colonies en septembre 1752), deux facteurs de corrections ont été ajoutés pour rendre le cycle plus précis.

Liste de paramètres

year

L'année, sous la forme d'un nombre compris entre 1970 et 2037

Valeurs de retour

La date pour Pâques, sous la forme d'un timestamp unix.

Historique

Version Description
Depuis la version 4.3.0 Le paramètre year est optionnel et vaut par défaut l'année courante vis à vis de l'heure locale.

Exemples

Exemple #1 Exemple avec easter_date()

<?php

echo date("M-d-Y"easter_date(1999));        // Apr-04-1999
echo date("M-d-Y"easter_date(2000));        // Apr-23-2000
echo date("M-d-Y"easter_date(2001));        // Apr-15-2001

?>

Voir aussi

  • easter_days() - Retourne le nombre de jours entre le 21 Mars et Pâques, pour une année donnée pour le calcul de Pâques avant 1970 et après 2037



easter_days> <cal_to_jd
[edit] Last updated: Fri, 10 Feb 2012
 
add a note add a note User Contributed Notes easter_date
py dot lebecq at gmail dot com 11-Mar-2010 07:44
I recently had to write a function that allows me to know if today is a holiday.

And in France, we have some holidays which depends on the easter date. Maybe this will be helpful to someone.

Just modify in the $holidays array the actual holidays dates of your country.

<?php
/**
 * This function returns an array of timestamp corresponding to french holidays
 */
protected static function getHolidays($year = null)
{
  if (
$year === null)
  {
   
$year = intval(date('Y'));
  }
   
 
$easterDate  = easter_date($year);
 
$easterDay   = date('j', $easterDate);
 
$easterMonth = date('n', $easterDate);
 
$easterYear   = date('Y', $easterDate);

 
$holidays = array(
   
// These days have a fixed date
   
mktime(0, 0, 0, 11$year),  // 1er janvier
   
mktime(0, 0, 0, 51$year),  // Fête du travail
   
mktime(0, 0, 0, 58$year),  // Victoire des alliés
   
mktime(0, 0, 0, 714, $year),  // Fête nationale
   
mktime(0, 0, 0, 815, $year),  // Assomption
   
mktime(0, 0, 0, 11, 1$year),  // Toussaint
   
mktime(0, 0, 0, 11, 11, $year),  // Armistice
   
mktime(0, 0, 0, 12, 25, $year),  // Noel

    // These days have a date depending on easter
   
mktime(0, 0, 0, $easterMonth, $easterDay + 2$easterYear),
   
mktime(0, 0, 0, $easterMonth, $easterDay + 40, $easterYear),
   
mktime(0, 0, 0, $easterMonth, $easterDay + 50, $easterYear),
  );

 
sort($holidays);
 
  return
$holidays;
}
?>
peter dot burden at gmail dot com 28-Jan-2010 04:55
In 5.3.1 easter_date() returns GMT of start of Easter Day in UK allowing
for UK Summer Time. If you are in another time zone you need to
calculate offsets.
<?php
        $e1
= easter_date(2008);
       
$e2 = easter_date(2009);
        echo
"Timestamps " . $e1 . " " . $e2 . "\n";

       
//      Timestamps 1206230400 1239490800

       
echo "Days between Easter 2008 Easter 2009 = " . ($e2-$e1)/86400 . "\n";

       
//      Days between Easter 2008 Easter 2009 = 384.958333333 - i.e. 384 days 23 hours

       
date_default_timezone_set("Europe/London");
        echo
date( " l, jS F Y H:i TO",$e1) . "\n";
        echo
date( " l, jS F Y H:i TO",$e2) . "\n";

       
//      Sunday, 23rd March 2008 00:00 GMT+0000
        //      Sunday, 12th April 2009 00:00 BST+0100

       
date_default_timezone_set("America/New_York");
        echo
date( " l, jS F Y H:i TO",$e1) . "\n";
        echo
date( " l, jS F Y H:i TO",$e2) . "\n";

       
//      Saturday, 22nd March 2008 20:00 EDT-0400
        //      Saturday, 11th April 2009 19:00 EDT-0400
        //      Daylight saving time in effect - New York 4 hours behind GMT
?>
maxie 12-Jun-2008 01:36
To compute the correct Easter date for Eastern Orthodox Churches I made a function based on the Meeus Julian algorithm:

<?php
function orthodox_eastern($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;
}
?>
nigelf at esp dot co dot uk 28-Jan-2008 03:50
v5.2.1 - There is a known bug with easter_date() that can return incorrect dates for some years:

<?php
// 2008 OK
echo date("D d M Y", easter_date(2008));  // Sun 23 Mar 2008

// 2009 returns Saturday
echo date("D d M Y", easter_date(2009));  // Sat 11 Apr 2009
?>


However easter_days() works correctly:

<?php
echo date("D d M Y", strtotime("2009-03-21 +".easter_days(2009)." days"));  // Sun 12 Apr 2009
?>

It is apparently related to timezone settings.
14-Aug-2006 07:46
I made the function like this ... works fine !

<?php
function ostern
{
   
$maerz21=date('z',mktime(0,0,0,3,21,$jb));

   
$d=((15 + $jb/100 - $jb/400 - (8 * $jb/100 + 13) / 25)%30 + 19 * ($jb%19))%30;

    if (
$d==29)
    {
       
$D=28;
    }
    elseif(
$d==28 && ($jb%17)>=11)
    {
       
$D=27;
    }
    else
$D=$d;   

   
$e=(2 * ($jb%4) + 4 *($jb%7) + 6 * $D + (6 + $jb/100 - $jb/400 - 2)%7)%7;

   
$ostersonntag=$e+$D+1+$maerz21;
    return
$ostersonntag;
}
?>
phpuser 08-Nov-2004 08:17
The algorithm from Bigtree is correct if you add some (int) cast
<?php
  
function easter_date ($Year) {
  
      
/*
       G is the Golden Number-1
       H is 23-Epact (modulo 30)
       I is the number of days from 21 March to the Paschal full moon
       J is the weekday for the Paschal full moon (0=Sunday,
         1=Monday, etc.)
       L is the number of days from 21 March to the Sunday on or before
         the Paschal full moon (a number between -6 and 28)
       */
      

        
$G = $Year % 19;
        
$C = (int)($Year / 100);
        
$H = (int)($C - (int)($C / 4) - (int)((8*$C+13) / 25) + 19*$G + 15) % 30;
        
$I = (int)$H - (int)($H / 28)*(1 - (int)($H / 28)*(int)(29 / ($H + 1))*((int)(21 - $G) / 11));
        
$J = ($Year + (int)($Year/4) + $I + 2 - $C + (int)($C/4)) % 7;
        
$L = $I - $J;
        
$m = 3 + (int)(($L + 40) / 44);
        
$d = $L + 28 - 31 * ((int)($m / 4));
        
$y = $Year;
        
$E = mktime(0,0,0, $m, $d, $y);

         return
$E;

   }
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites