PHP - Get dates of next 5 weekdays?
Posted
by
Dan
on Stack Overflow
See other posts from Stack Overflow
or by Dan
Published on 2013-06-28T09:57:23Z
Indexed on
2013/06/28
10:21 UTC
Read the original article
Hit count: 249
I'm trying to create an array of the next 5 working week days (Monday - Friday, excluding today). I know the working week varies around the world but this is not important for what I am trying to do.
So, for example, if today is a Wednesday, I want the dates for Thursday and Friday of the current week and Monday, Tuesday and Wednesday of the following week.
I thought this would work:
$dates = array();
for ($i = 1; $ < 6; $i ++)
{
$dates[] = date('Y-m-d', strtotime('+ '.$i.' weekday'));
}
But for today, it is giving me:
- Monday 1st
- Tuesday 2nd
- Wednesday 3rd
- Thursday 4th
- Sunday 7th!
Any advice appreciated.
Thanks
© Stack Overflow or respective owner