Find Weekdays Range for a particular date in php

$startDatestr = strtotime('monday this week', strtotime(str_replace('/', '-', $selDate)));
$startDate = date('Y-m-d', strtotime('monday this week', $startDatestr));
$endDate = date('Y-m-d', strtotime('friday this week', $startDatestr));

$start = new DateTime($startDate);
$end = new DateTime($endDate);
$invert = $start > $end;
$format = 'Y-m-d';

$dates = array();
$dates[] = ($start->format($format)); 
while ($start != $end) {
$start->modify(($invert ? '-' : '+') . '1 day');
$dates[] = $start->format($format); 
}
return $dates;

$selDateĀ : ’09/10/2014′

$dates : ’06/10/2014′, ’07/10/2014′, ’08/10/2014′, ’09/10/2014′, ’10/10/2014′.

Leave a Reply