holidaysus

holidays_us
SYNOPSIS

holidays_us($year=false)

DESCRIPTION

holidays_us returns the list of holidays in the USA (Federal Days) for the year $year or the current year by default.

CODE
  1. function holidays_us($year=false) {
  2.     if (!$year) {
  3.         $year = intval(date('Y'));
  4.     }
  5.  
  6.     function _adjustday($date) {
  7.         static $oneday=24*60*60;
  8.  
  9.         $weekday=date('w', $date);
  10.  
  11.         if ($weekday == 0) {
  12.             return $date + $oneday;
  13.         }
  14.         else if ($weekday == 6) {
  15.             return $date - $oneday;
  16.         }
  17.  
  18.         return $date;
  19.     }
  20.  
  21.     $holidays = array(
  22.         _adjustday(mktime(0, 0, 0,  1,  1, $year)),                 // New Year's Day
  23.         strtotime("3 Mondays", mktime(0, 0, 0, 1, 1, $year)),       // Birthday of Martin Luther King, Jr.
  24.         strtotime("3 Mondays", mktime(0, 0, 0, 2, 1, $year)),       // Wasthington's Birthday
  25.         strtotime("last Monday of May $year"),                      // Memorial Day
  26.         _adjustday(mktime(0, 0, 0,  7,  4, $year)),                 // Independence day
  27.         strtotime("first Monday of September $year"),               // Labor Day
  28.         strtotime("2 Mondays", mktime(0, 0, 0, 10, 1, $year)),      // Columbus Day
  29.         _adjustday(mktime(0, 0, 0, 11, 11, $year)),                 // Veteran's Day
  30.         strtotime("4 Thursdays", mktime(0, 0, 0, 11, 1, $year)),    // Thanksgiving Day
  31.         _adjustday(mktime(0, 0, 0, 12, 25, $year)),                 // Christmas
  32.     );
  33.  
  34.     return $holidays;
  35. }
SEE ALSO

holidays_fr

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].