HartleySan Posted April 18, 2012 Share Posted April 18, 2012 Is there any easy way to use the Date object in JS to check whether a specific date is a holiday or not? Of course, I know that the holidays differ by country and region, so it's probably a bit much to ask, but I'm trying to avoid having to write a bunch of algorithms for calculating all the holidays for a given country depending on the year. Any advice would be much appreciated. Thank you. Link to comment Share on other sites More sharing options...
HartleySan Posted April 18, 2012 Author Share Posted April 18, 2012 I should add, if there's any sort of PHP solution, that's completely acceptable as well. Thanks. Link to comment Share on other sites More sharing options...
Paul Swanson Posted April 18, 2012 Share Posted April 18, 2012 Found this JS function via a Google search: http://www.softcomplex.com/forum/viewthread_2814/ Looks like it should work for you. 1 Link to comment Share on other sites More sharing options...
HartleySan Posted April 18, 2012 Author Share Posted April 18, 2012 Yeah, I actually saw that too, and it's a possibility. Without going into too much detail though, I'm not interested in American holidays, and I know that there are holidays that change from year to year, so I'll have to either compute them, or just store them in a DB for years in advance, which might just be the best thing to do. Thanks a lot. Link to comment Share on other sites More sharing options...
Larry Posted April 18, 2012 Share Posted April 18, 2012 It sounds like storing them in the database is the prudent solution. Link to comment Share on other sites More sharing options...
HartleySan Posted April 19, 2012 Author Share Posted April 19, 2012 Yeah, I suppose with all the info on the Internet these days, I can quickly look up all the dates for the next few years, and then update them down the road if need be. Thanks. Link to comment Share on other sites More sharing options...
Larry Posted April 19, 2012 Share Posted April 19, 2012 My first inclination would be to find a service that would provide that information for you that you could hook into. But you're not asking for information that changes frequently or is that large, so it'd just be easier and more efficient to create it on your own system. My thoughts anyway... Link to comment Share on other sites More sharing options...
HartleySan Posted April 19, 2012 Author Share Posted April 19, 2012 Yeah, and that's what I'm thinking to. For the time being, I will just feed the data into a DB directly, but more long term, I may write a function (or functions) for calculating all the necessary holidays in a given year. Link to comment Share on other sites More sharing options...
Recommended Posts