Hi,
I am importing data from a csv file into mysql.
Everything works fine except that the 'order_date' column in CSV is in the following format mm/dd/yy.
Upon import I would like for that format to be changed to yyyy-mm-dd
I am not sure how to modify the following code to be able to do so.
Any help would be appreciated.
<?
include "connect.php";
if(isset($_POST['submit']))
{
$filename=$_POST['filename'];
$handle = fopen("$filename", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$date = date("Y-m-d");
$import="INSERT into table
(order_id,
order_status,
order_date,
todays_date)
values
('$data[0]',
'$data[1]',
'$data[2]',
'$date')";
mysql_query($import) or die(mysql_error());
}
fclose($handle);
print "Import done";
}
else
{
print "<form action='importnew.php' method='post'>";
print "Type file name to import:<br>";
print "<input type='text' name='filename' size='20'><br>";
print "<input type='submit' name='submit' value='submit'></form>";
}
?>