Re: [PHP] Last working day of a month
- From: jochem@xxxxxxxxxxxxx (Jochem Maas)
- Date: Thu, 04 Dec 2008 16:15:05 +0100
Angelo Zanetti schreef:
Hi all,
I am busy trying to figure out how to get the last working day in a month.
I was wondering if there was a script already written, but this is what I
imagine should work:
Get the current day and see if it's the last day of the month. If its true
check if it's a Saturday or Sunday if it's either of those 2 days then
return false else return true?
I also need to take public holidays into account. What would be the best
solution for that? Store the public holidays in a table and check if the
current day isn't a public holiday?
you need a process with a few simple steps.
1. find the last day of the month, this is quite easy ... google gives answers
as does the manual. e.g.:
http://lutrov.com/blog/php-last-day-of-the-month-calculation/
2. determine if this is a week day. if yes go to step three else 'roll the date back'
24 hours and go to step 2.
3. determine if this is a holiday, if yes 'roll the date back' 24 hours and go
to step 2. else you have found the last working day of the month.
with regard to determining if a day is a holiday your best bet is to store these
in a database table. and check against that ... you may be able to find a source
of holiday data online from which you can sync your local datasource periodically
(e.g. via a cron job).
hth
Any advice is appreciated.
TIA
Angelo
Web: http://www.elemental.co.za
.
- Follow-Ups:
- Re: [PHP] Last working day of a month
- From: Govinda
- Re: [PHP] Last working day of a month
- References:
- Last working day of a month
- From: "Angelo Zanetti"
- Last working day of a month
- Prev by Date: RE: [PHP] Last working day of a month
- Next by Date: Exceptions - when and why?
- Previous by thread: RE: [PHP] Last working day of a month
- Next by thread: Re: [PHP] Last working day of a month
- Index(es):
Relevant Pages
|