I'm using this function to get all Fridays between two dates:
public function getFridaysInRange($dateFromString, $dateToString)
{
$dateFrom = new \DateTime($dateFromString);
$dateTo = new \DateTime($dateToString);
$dates = [];
if ($dateFrom > $dateTo) {
return $dates;
}
if (1 != $dateFrom->format('N')) {
$dateFrom->modify('next friday');
}
while ($dateFrom <= $dateTo) {
$dates[] = $dateFrom->format('Y-m-d');
$dateFrom->modify('+1 week');
}
return $dates;
}
$this->getFridaysInRange('2017-01-01','2017-01-30');
result :
array:4 [▼
0 => "2017-01-06"
1 => "2017-01-13"
2 => "2017-01-20"
3 => "2017-01-27"
]
Is there any function in carbon
like above?