Page 1 sur 1

récupérer date au format 'Ymd'

Posté : 22 juin 2022, 10:57
par ChrisCMoi62
Bonjour,
J'ai un champ SQL au format date, je voudrai l'insérer dans une variable au format "Ymd", j'ai testé ceci mais ça ne fonctionne pas
Merci de votre aide.

Code : Tout sélectionner

$champ= date('Ymd', $_POST[ 'madate' ]);

Re: récupérer date au format 'Ymd'

Posté : 22 juin 2022, 11:24
par ChrisCMoi62
J'ai trouvé quelque chose qui fonctionne :-)
Bonne journée

Code : Tout sélectionner

$champ= date('Ymd', strtotime(str_replace('','-',$_POST['madate'])));