Import different type date from csv

I try to import date from csv file like dd.mm.yyyy in my mysql database and the date in csv file is dd/mm/yyyy. How to convert data? This is my code:

[php]

<?php header("Content-Type: text/html; charset=utf8_unicode"); ?> <?php

$connec = mysql_connect(‘localhost’,’*’,'’);
mysql_select_db(‘export’, $connec);

$sql = "LOAD DATA LOCAL INFILE ‘purchase_invoice.csv’

                INTO TABLE invoice
                FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
                LINES TERMINATED BY '\r\n'
                IGNORE 1 LINES
                ";

mysql_query($sql);
if(mysql_error()) {
echo(mysql_error());
} else {
echo(“Import sucessfull data imported to mysql table.”);
}
?>
[/php]

If they are both strings, just replace the ‘.’ with ‘/’… $date=str_replace(".", “/”, $date);

Sponsor our Newsletter | Privacy Policy | Terms of Service