I make a massive import module of an excel.csv file but in my date field (DATE) it does not insert the data correctly, it only inserts 0000-00-00
, the other fields in the import do it without problem it is only in the date field.
Thanks / Regards
Here is an example of the lines that are inserted in the excel.csv file
7;01/12/2017;5:46:00;;;
7;01/12/2017;15:02:00;;;
10;26/11/2017;22:37:00;;;
10;27/11/2017;5:59:00;;;
<?php
if (isset($_POST["enviar"])) {//nos permite recepcionar una variable que si exista y que no sea null
require_once("conexion_excel.php");
require_once("functions.php");
$archivo = $_FILES["archivo"]["name"];
$archivo_copiado= $_FILES["archivo"]["tmp_name"];
$archivo_guardado = "copia_".$archivo;
//echo $archivo."esta en la ruta temporal: " .$archivo_copiado;
if (copy($archivo_copiado ,$archivo_guardado )) {
//echo "se copeo correctamente el archivo temporal a nuestra carpeta de trabajo <br/>";
}else{
//echo "hubo un error <br/>";
}
if (file_exists($archivo_guardado)) {
$fp = fopen($archivo_guardado,"r");//abrir un archivo
$rows = 0;
while ($datos = fgetcsv($fp , 1000 , ";")) {
$rows ++;
// echo $datos[0] ." ".$datos[1] ." ".$datos[2]." ".$datos[3] ."<br/>";
if ($rows > 1) {
$resultado = insertar_datos($datos[0],$datos[1],$datos[2]);
if($resultado){
//echo "se inserto los datos correctamente<br/>";
}else{
//echo "no se inserto <br/>";
}
}
}
}else{
echo "No existe el archivo copiado <br/>";
}
}
?>