Re: Last working day of a month

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 
> 
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux