Reputation: 3485
I need to know the first day-of-week in a given time period. The day of the week will change so it could be Sunday, Monday, Tuesday, Wednesday, Thursday, or Friday. For example: I need to find the first Monday between 2011-10-30 and 2011-12-11.
Upvotes: 0
Views: 705
Reputation: 522101
Just a little math with the date('N')
(day of the week) value:
$timestamp = strtotime('2011-11-08');
$weekday = date('N', $timestamp);
if ($weekday > 1) {
$timestamp = strtotime('+' . abs(8 - $weekday) . ' days', $timestamp);
}
echo date('D Y-m-d', $timestamp);
Upvotes: 1