Jump to content

Return array of next x working days


John_A

Recommended Posts

Hi,

 

I need a function to return the next x working days (Mon - Fri). So for 7 from today it would return: -

 

Monday 8th March

Tuesday 9th March

Wednesday 10th March

Thursday 11th March

Friday 12th March

Monday 15th March

Tuesday 16th March

 

But also with the ability to pass to it days to be excluded (for example Christmas / Boxing day and New Year's Day, as well as any custom public holidays).

 

I've done something similar before but it ended up being rather long, I'm looking to keep this as short and simple as possible....any ideas?

Link to comment
https://forums.phpfreaks.com/topic/194438-return-array-of-next-x-working-days/
Share on other sites

You could probably make a loop and check for Saturday / Sunday, if it is equal to that then omit.

 

For the holidays, well you would have to take into account the "Observed" Holiday and calculate that, so you could not just simply define a date and viola! But it would be the same type of deal, if the date is equal to this date (either hardcoded in there or into an array) then you omit it and continue onwards.

 

I am sure there are plenty of Calendar scripts that have this functionality that you could look at the decipher to create your own special function.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.