PHP is holiday class

Test out is it a holiday for any given date.

This class currently support United States and Canada’s holidays.

Here is
United States holidays information.
Canadian Holidays information.

This PHP class supports different provinces have its own provincial holidays. For example, December 26th is statutory holiday for Ontario and New Brunswick in Canada.

Usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
include_once("IsHoliday.php");
 
$h = new Holiday('US');
if($h->is_holiday('2010-07-04')) 
        echo "yes, 2010-07-04 is holiday in US <br>";
else	
        echo "no <br>";
 
 
//Using Canadian province code for specific province
$h = new Holiday('Canada','ON');
if($h->is_holiday('2010-12-26')) 
        echo "yes, 2010-12-26 is holiday in Canada <br>";
else	
        echo "no <br>";
?>

Download source code here

  • Share/Save/Bookmark

2 Responses to “PHP is holiday class”

  1. Peter says:

    Thanks – This class was useful for me to calculate the next business day to get accurate shipping quotes from UPS. Saved me a bunch of time. Thanks.

  2. Thanks for the function.

    This seems to arrive at the last monday in April rather than May for memorial day, “Last Monday” in strtotime is interpreted as “the last Monday” rather than “the last Monday in the month”. I think this can be fixed by changing the “05-Last Monday” to “06-Last Monday. I haven’t tested this against the boundary condition of June 1st being a Monday but in any case, this should get someone a step closer to having Memorial Day right.

Leave a Reply