1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
public function getMonthLibelleByDates($filtre) {
$format1 = []; $format2 = [];
$month = time(); // ici vaous appelez time() qui est donc un nombre
for ($i = 1; $i <= 12; $i++) {
$month = strtotime('last month', $month);
$months[] = date("r", $month);
}
foreach($months as $mois) { //ici vous essayez de boucler sur le nombre renvoyé par time()
array_push($format1, $mois->format('M-Y')); // cette méthode n'existe donc pas.... d'où l'erreur.
array_push($format2, $mois->format('Y-m-d'));
}
$response = array(
'format1'=> $format1,
'format2' => $format2
);
return $response;
} |
Partager