Bonsoir,

voici une fonction qui retourne une variable de type DateTime, sauf que ce retour n'est pas accepté. Pourquoi ? Merci.

Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
    static public function SQLFormatDate($date): DateTime {
    if (UtilFct::contains("Earlier",$date)) $date='Dec-18';
    $formats = ['d/m/Y H:i','M d, Y', 'M d Y', 'M,d', 'M-d'];
    foreach ($formats as $f) {
        if (($val=\DateTime::createFromFormat($f, $date)) !== false) {
            return ((DateTime)$val);
        }
    }
    return (DateTime)false;
}

Parse error: syntax error, unexpected '$val' (T_VARIABLE), expecting ';' in C:\wamp64\www\ticket2\Classes\Olivier\Validator.php on line 58