I have this method :
public function getYears($startYear = 1990, $endYear = date ('Y')){
$years = [];
$date = new \DateTime();
$years[$date->format('Y')] = $date->format('Y');
while ($endYear <= $startYear){
$date->add(new \DateInterval('P1Y'));
$years[$date->format('Y')] = $date->format('Y');
$endYear++;
}
return $years;
}
This piece of code doens't work, but you get the idea what I want ? How can i make this work ? thx