Re: Last working day of a month

From: Date: Thu, 04 Dec 2008 15:37:07 +0000
Subject: Re: Last working day of a month
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-284099@lists.php.net to get a copy of this message
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
Well it should!! The advice I love most of all is like this, helping me see the clear logic, and then letting me figure out how to write it w/the language at hand. This reply post of mine does not add anything for anyone; sometimes I just can't help express my appreciation for things. Brilliant Jochem! -G

« previous php.general (#284099) next »