I have a form which is used to upload a .csv file to insert data in mysql table. The file has a date column in a format "dd/mm/yyy". However I want to insert this date string in mysql date format "yyyy-mm-dd". I have the following code so far.
//parse data from csv file line by line
while(($line = fgetcsv($csvFile)) !== FALSE){
//insert member data into database
$db->query("INSERT INTO txns (txn_date, description, amount, status) VALUES ('".$line[0]."','".$line[1]."','".$line[2]."','".$line[3]."','".$line[3]."')");
}
}
//close opened csv file
fclose($csvFile);
Please help to convert the date string to mysql date (yyyy-mm-dd) format.