Import csv with wrong format date to MySQL with Symfony-php

  csv, mysql, php, symfony

I’m trying to upload a csv file to my mysql table with symfony/php.


while (($data = fgetcsv($handle, 0, ";")) !== false) {

                    if ($count == 1) { continue; }

                    $entity = new Oasice();
                    $entity->setDateAmeoAmheo($data[7]); // date
                    // a lot more column...

In this file I have ten columns with dates in the format dd/mm/YYYY which poses a problem for the integration into the database.

I tried the solutions I could find so far (like for example: this) but nothing conclusive.


$date = date("Y-m-d", strtotime(str_replace('/', '-', $data[7])));

but my result is often 01-01-1970 or 1970-01-01.

How should I go about it please? what am I doing wrong ?

Source: Symfony Questions