0
I have a function to import data from a txt document, the layout that I use to import this data is delimited by semicolon, I have the following columns (number, data_inclusion, sender, currency, value, status). The problem is time to insert the date, because in txt I use the Brazilian standard dd/mm/yyyy and in mysql it does not accept this standard, as I do to convert this date to the American standard before running the Insert?
my code:
<?php
function Inserir($itens, Pdo $pdo){
$sts = $pdo->prepare("INSERT INTO orpags(numero,data_inclusao,remetente,moeda,valor,situacao,status) VALUES(?,?,?,?,?,?,'1');");
$sts->bindValue(1, $itens[0], PDO::PARAM_STR);
$sts->bindValue(2, $itens[1], PDO::PARAM_STR);
$sts->bindValue(3, $itens[2], PDO::PARAM_STR);
$sts->bindValue(4, $itens[3], PDO::PARAM_STR);
$sts->bindValue(5, $itens[4], PDO::PARAM_STR);
$sts->bindValue(6, $itens[5], PDO::PARAM_STR);
$sts->execute();
$sts->closeCursor();
$sts = NULL;
/* por ponto e virgula*/
}
if (!empty($_FILES['arquivo']))
{
$Pdo = new PDO("mysql:host=localhost;dbname=smoke", "root", "");
$file = fopen($_FILES['arquivo']['tmp_name'], 'r');
while (!feof($file)){
$linha = fgets($file);
$itens = explode(';', $linha);
Inserir($itens, $Pdo);
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Arquivo</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" enctype="multipart/form-data" method="post">
<input type="file" name="arquivo" id="arquivo">
<input type="submit" name="enviar" value="Enviar">
</form>
</body>
</html>
The function
strtotime
does not accept the Brazilian standard as a parameter (see this example). List of accepted standards– Gabriel Heming