If I start with the current date, how can I get the first Friday of each month?
I was thinking about using $date->get(Zend::WEEKDAY) and comparing that to Friday and then with DAY and checking if it is less than or equal to 7. Then adding 1 month onto it.
There must be something simpler?
How about
Or turn it into a handy function:-
You could use this with Zend_Date like this:-
Then
Zend_Debug::dump($zDate->toString());
will produce :-I'd say that's a lot simpler :)
Edit after some more thought:
A more generalised function may be of more use to you, so I'd suggest using this:-
These days my preferred method is to extend PHP's DateTime object:-
Gives:-