Is there a function wich can convert a date in format like :
31/07/2014 to a format date like 2014-07-31
I want to do this because in my sql query when i put the date in the format with " / " it doesn't understand te format :/
I have this message : Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '30/07/2014' for column 'date_recu' at row 1' in C:\wamp\www\ajouter_lot2.php on line 76
in my sql table, the type of the date is in datetime.
Query
$bdd->query('insert into LOT (id_lot,num_ref,date_recu,qty,remarque1,remarque2)
VALUES
(NULL, "'.$Num_Ref.'","'.$Date_Recu.'",\''.$Qty.'\',"'.$Rem1_Lot.'","'.$Rem2_Lot.'")');
Where $Date_Recu = "31/07/2014"
Solution with strtotime()
$Date_Recu = strtotime($Date_Recu); /* shows 31/07/2014 */
$Date_Recu = date('Y-m-d', $Date_Recu);
echo 'Date Recu : '.$Date_Recu; /* shows 2014-07-31 */