easter_days

(PHP 4, PHP 5)

easter_days — Get number of days after March 21 on which Easter falls for a given year

Описание

int easter_days ([ int $year [, int $method ]] )

Returns the number of days after March 21 on which Easter falls for a given year. If no year is specified, the current year is assumed.

This function can be used instead of easter_date() to calculate Easter for years which fall outside the range of Unix timestamps (i.e. before 1970 or after 2037).

The date of Easter Day was defined by the Council of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox. The Equinox is assumed to always fall on 21st March, so the calculation reduces to determining the date of the full moon and the date of the following Sunday. The algorithm used here was introduced around the year 532 by Dionysius Exiguus. Under the Julian Calendar (for years before 1753) a simple 19-year cycle is used to track the phases of the Moon. Under the Gregorian Calendar (for years after 1753 - devised by Clavius and Lilius, and introduced by Pope Gregory XIII in October 1582, and into Britain and its then colonies in September 1752) two correction factors are added to make the cycle more accurate.

(The code is based on a C program by Simon Kershaw, <webmaster at ely.anglican dot org>)

Список параметров

year

The year as a positive number

method

Allows to calculate easter dates based on the Gregorian calendar during the years 1582 - 1752 when set to CAL_EASTER_ROMAN. See the calendar constants for more valid constants.

Возвращаемые значения

The number of days after March 21st that the Easter Sunday is in the given year .

Список изменений

Версия Описание
Since 4.3.0 The year parameter is optional and defaults to the current year according to the local time if omitted.
Since 4.3.0 The method parameter was introduced.

Примеры

Пример #1 easter_days() example

<?php

echo easter_days(1999);        // 14, i.e. April 4
echo easter_days(1492);        // 32, i.e. April 22
echo easter_days(1913);        //  2, i.e. March 23

?>

Смотрите также

Коментарии

Also, be aware that the eastern orthodox churches sometimes have different dates for easter. See, for example <http://webexhibits.org/calendars/calendar-christian-easter.html>. And note that the dates of easter a subject to change,  for example, the churches might some day decide to unify the dates.
2001-11-19 13:43:50
http://php5.kiev.ua/manual/ru/function.easter-days.html
This function returns an array of timestamp corresponding to Dutch National holidays. Liberation Day (Bevrijdingsdag) is added as a National holiday once every five years (2000, 2005, 2010, ...).

<?php
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(
       
// Nieuwjaarsdag
       
mktime(00011$year), 
       
// 1e Kerstdag
       
mktime(0001225$year), 
       
// 2e Kerstdag
       
mktime(0001226$year)
    );
     
   
// Bevrijdingsdag
   
if (($year 5) == 0) {
       
$holidays[] = mktime(00055$year); 
    }
   
   
// Koninginnedag (< 2014) of Koningsdag (>= 2014). 
    // Verplaats naar zaterdag als het valt op zondag.
   
if ($year <= 2013) { // Koninginnedag <= 2013
       
if (date('w'mktime(000430$year)) == 0) { // Op zondag?
           
$holidays[] = mktime(000429$year);  // Verplaats naar zaterdag
       
} else {
           
$holidays[] = mktime(000430$year);  // Koninginnedag
       
}
    } else { 
// Koningsdag > 2014
       
if (date('w'mktime(000427$year)) == 0) { // Op zondag?
           
$holidays[] = mktime(000426$year);  // Verplaats naar zaterdag
       
} else {
           
$holidays[] = mktime(000427$year);  // Koningsdag
       
}
    }
   
   
// Onderstaande dagen hebben een datum afhankelijk van Pasen
    // Goede Vrijdag (= pasen - 2)
   
$holidays[] = strtotime('-2 days'mktime(000$easterMonth$easterDay$easterYear));
   
// 1e Paasdag
   
$holidays[] = mktime(000$easterMonth$easterDay$easterYear);
   
// 2e Paasdag (= pasen +1)
   
$holidays[] = strtotime('+1 days'mktime(000$easterMonth$easterDay$easterYear));
   
// Hemelvaartsdag (= pasen + 39)
   
$holidays[] = strtotime('+39 days'mktime(000$easterMonth$easterDay$easterYear));
   
// 1e Pinksterdag (= pasen + 49)
   
$holidays[] = strtotime('+49 days'mktime(000$easterMonth$easterDay$easterYear));
   
// 2e Pinksterdag (= pasen + 50)
   
$holidays[] = strtotime('+50 days'mktime(000$easterMonth$easterDay$easterYear));

   
sort($holidays);
 
    return 
$holidays;
}

$holidays getHolidays(2014);

foreach (
$holidays as $holiday) {
    echo 
date('d-M-Y'$holiday) . '<br>';
}
?>
2015-06-01 18:20:31
http://php5.kiev.ua/manual/ru/function.easter-days.html

    Поддержать сайт на родительском проекте КГБ