This question already has an answer here:
I have a SQL table imported from an CSV excel sheet with PHP. The import wasn't optimized to detect dates and create column type Date while creating the table which now has a 'varchar' column with dates like 7-Feb, 8-Feb etc. But now I do not have the excel sheet to change the format there and re import. So I need to convert the data in the imported database from the 7-Feb format to yyyy-mm-dd for all rows. The reason being, if I change the column type from 'Varchar' to 'Date'now, the string is not recognized and becomes 0000-00-00. And I lose my information. So I have to change the varchar string to date format before changing the column type.
Is this possible with php ?
</div>
<?php
$dateSet = array('7-Feb','8-Feb','9-Feb-2018');
foreach($dateSet as $date){
$newDate = date('Y-m-d',strtotime($date));
var_dump($newDate);
}
Should do it nicely