-1

I am working on import the csv file into the database using php.

For that I written php code like below.

<?php
$conn = mysqli_connect("localhost", "db_user", "db_password", "db_name");
$sqlInsert = "INSERT into table_name (first_name,last_name,email_address,join_date) values ('" . $column[0] . "','" . $column[1] . "','" . $column[2] . "','" . $column[3] . "')";
$result = mysqli_query($conn, $sqlInsert);
?>

Now I am having csv file with the following date formates (example:(%d-%m-%y) and (%d/%m/%y) ).

Note: I have set the date column in "DATE" data type in database.

So in the csv file having both the format, we need to convert it to one format while importing.

How can I convert it to default format like "(Y-m-d)" ?

Skumar
  • 3
  • 4

1 Answers1

0
  • try this date_format($date,"Y/m/d H:i:s"); or date_format($date,"Y/m/d");
sandip bharadva
  • 629
  • 1
  • 6
  • 19
  • Okay Some date like "2011/05/22" and "2011-05-22". How can we convert these to "2011-05-22" – Skumar Jun 28 '18 at 07:08