Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP how to check if a day was a holiday (in a specified country)?

Tags:

php

Is there some function that would tell me if a date was a holiday in a certain country?

I know this is probably futile question as it would be difficult to have a function like that.

like image 990
Richard Knop Avatar asked Jan 19 '11 09:01

Richard Knop


3 Answers

I might be wrong, but I think you are going to have to roll your own. And even if there is already a lib that does this for you, you are going to have to be careful - the definition of holiday will vary, even for a given country. (E.g does a religious holiday mean the banks are shut?). I.e what constitutes a holiday is likely to be application dependent. Take a look at this wikipedia page for lists of national holidays: http://en.wikipedia.org/wiki/List_of_holidays_by_country

like image 79
Richard H Avatar answered Nov 09 '22 11:11

Richard H


There is no built-in function for this, but you might be able to roll-your-own using the holiday script at AbleDesign as the base

like image 39
Mark Baker Avatar answered Nov 09 '22 11:11

Mark Baker


Rather late in posting an answer, but as the current maintainer of the relevant PEAR Packages, I would suggest that you utilise the Date Holidays suite of components from PEAR. There are drivers for most countries: Australia, USA, UK, Germany, Russia and others.

like image 2
kguest Avatar answered Nov 09 '22 11:11

kguest