Introduction (Previous) (Next) Encryption

View this page in Last updated: Sun, 29 Jun 2008
English | French | German | Hungarian | Japanese | Polish | Spanish | Plain HTML

Example

Example -- Example for the usage of Date_Holidays

Basic example

This example shows you, how to calculate the Easter date of 2005.


<?php
require_once "Date/Holidays.php";
$germany = &Date_Holidays::factory('Germany'2004'en_EN');
if (Date_Holidays::isError($germany)) {
    die('Factory was unable to produce driver-object');
}
$easter = &$germany->getHoliday('easter''de_DE');
if (!Date_Holidays::isError($easter)) {
    print_r($easter->toArray());
}
?>

This will return an array in the following format:

Array
(
    [internalName] => easter
    [title] => Easter Sunday
    [date] => date Object
        (
            [year] => 2004
            [month] => 04
            [day] => 11
            [hour] => 0
            [minute] => 0
            [second] => 0
            [tz] => date_timezone Object
                (
                    [id] => UTC
                    [longname] => Coordinated Universal Time
                    [shortname] => UTC
                    [hasdst] =>
                    [dstlongname] => Coordinated Universal Time
                    [dstshortname] => UTC
                    [offset] => 0
                    [default] =>
                )

        )

)
Introduction (Previous) (Next) Encryption

Download Documentation Last updated: Sun, 29 Jun 2008
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: kguest
This is an example of testing whether a specified date is considered a holiday [in Ireland].

require_once "Date/Holidays.php";
require_once "Date/Holidays/Filter/Ireland/Official.php";

//set up filter
$filter = new Date_Holidays_Filter_Ireland_Official();
//then the driver
$driver = &Date_Holidays::factory($country, $year);

//now test.
$dstr = '2007-04-06';
$workday = new Date($dstr);
if ($driver->isHoliday($workday, $filter)){
echo "{$dstr} is a holiday\n";
}