PHP code example of treehousetim / bank-holidays

1. Go to this page and download the library: Download treehousetim/bank-holidays library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

treehousetim / bank-holidays example snippets


abstract public function getAsArray() : array;
abstract public function getObservedAsArray() : array;



$year = 2021;
$bankHolidayCalc = new \treehousetim\bankHolidays\usa( $year );
$info = $bankHolidayCalc->getChristmasDayDetail();

if( $info['observed'] )
{
	echo 'In ' . $year . ', Christmas Day is not a bank holiday';
}
else
{
	echo 'In ' . $year . ', Christmas Day is a bank holiday and is observed on ' . $info['date'];
}



$bankHolidayCA = new \treehousetim\bankHolidays\canada( 2019 );
$date = $bankHolidayCA->familyDay();
echo $date;

$bankHolidayUS = new \treehousetim\bankHolidays\usa( 2019 );
$date = $bankHolidayUS->christmasDay();
echo $date;