I'm stuck in my php script for a blog where I want to display the time and date for all the articles. I created a function but I don't know why it doesn't want to work:
function articles(){ 
    global $bdd;
    $articles = $bdd->query("SELECT id, titre, accroche, contenu, publication, image FROM articles");
    $articles = $articles->fetchAll();
    return $articles;
}
function formattage_date($publication){ 
    $publication = explode(" ", $publication);
    $date = explode("-", $publication[0]);
    $heure = explode(":", $publication[1]);
    $mois = ["", "janvier", "fevrier", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "decembre"];
    $resultat = $date[2] . ' ' . $mois[$date[1]] . ' ' . $date[0] . ' à ' . $heure[0] . 'h' . $heure[1];
    return $resultat;
}
When I want to use $mois, php says: Notice: Undefined index: 03 in C:\wamp\www\entertheletter.dev\fonctions\blog.php on line 18
 
     
     
    