Я импортирую файл Excel в phpmyadmin, и он не получает правильный формат для даты. У меня это в файле excel как yyyy / mm / dd и в phpmyadmin появляется как 0000-00-00.
Я пробовал разные вещи в коде, но результат всегда один и тот же. Может быть, кто-то с той же проблемой может помочь мне.
Мой код для импорта файла следующий:
if(isset($_FILES["name"])){
$up = new Upload($_FILES["name"]);
if($up->uploaded){
$up->Process("./uploads/");
if($up->processed){
/// leer el archivo excel
require_once 'PHPExcel/Classes/PHPExcel.php';
$archivo = "uploads/".$up->file_dst_name;
$inputFileType = PHPExcel_IOFactory::identify($archivo);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($archivo);
//$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($x_FechaPedido);
//$timestamp = PHPExcel_Shared_Date::ExcelToPHP($x_FechaPedido);
//$fecha = date("Y-m-d H:i:s",$timestamp);
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
for ($row = 2; $row <= $highestRow; $row++){
$x_noCliente = $sheet->getCell("A".$row)->getValue();
$x_nombreCliente = $sheet->getCell("B".$row)->getValue();
$x_zv = $sheet->getCell("C".$row)->getValue();
$x_noPedido = $sheet->getCell("D".$row)->getValue();
$x_pedidoCliente = $sheet->getCell("E".$row)->getValue();
$x_FechaPedido = $sheet->getCell("F".$row)->getValue();
$x_importe = $sheet->getCell("G".$row)->getValue();
$x_contrPen = $sheet->getCell("H".$row)->getValue();
$x_pagoCont = $sheet->getCell("I".$row)->getValue();
$x_credEx = $sheet->getCell("J".$row)->getValue();
$x_deudaVen = $sheet->getCell("K".$row)->getValue();
$x_cr = $sheet->getCell("L".$row)->getValue();
$sql = "insert into pedidospendientes (noCliente, nombreCliente, zv, noPedido, pedidoCliente, FechaPedido, importe, contrPen, pagoCont, credEx, deudaVen, cr, created_at) value ";
$sql .= " (\"$x_noCliente\",\"$x_nombreCliente\",\"$x_zv\",\"$x_noPedido\",\"$x_pedidoCliente\",\"$x_FechaPedido\",\"$x_importe\",\"$x_contrPen\", \"$x_pagoCont\",\"$x_credEx\", \"$x_deudaVen\",\"$x_cr\",NOW())";
$mysqli->query($sql);
}
unlink($archivo);
}
}
}