Forum Moderators: coopster
$now = date('Y-m-d h:m:s', strtotime("now"));
echo $now."<br/>";
$some_date = '2009-01-25';
$found = 0;
$i=0;
while(!$found)
{
$find_monday = date("Y-m-d", strtotime('+'.$i.' monday'));
if($some_date > $find_monday )
{
echo "$find_monday is the monday you were looking for<br/>";
$found = 1;
break;
}
else
$i--;
}
For just previous Monday,
select date_add(curdate(), interval 0-weekday(curdate()) day);
Monday and Friday,
select date_add(curdate(), interval 0-weekday(curdate()) day) as Monday, date_add(curdate(), interval 4-weekday(curdate()) day) as Friday;
.... etc. ....