-1
I’m having another date problem. My mysql is at the right time, but when recording the date in an input with javascript is saving in UTC and not in GMT-0300. What can be?
<form id="formColeta">
<div class="row mx-auto">
<div class="form-group form-group-inline col-6">
<label class="text-left"><b>Cliente</b></label>
<input name="cliente" type="text" value="" id="cliente" placeholder="Cliente" autofocus required>
</div>
<div class="form-group form-group-inline col-6">
<label><b>Telefone</b></label>
<input name="telefone" type="number" value="" id="telefone" placeholder="123456789" required>
</div>
</div>
<div class="form-group form-group-inline col-12 mx-2">
<label><b>Observação</b></label>
<input class="col-12" name="observacao" type="text" value="" id="observacao" placeholder="Digite informação importante sobre a coleta">
</div>
<input name="data" type="hidden" id="data" value="<?php
$hoje = date('Y-m-d');
echo $hoje
?>">
<input name="hora" type="hidden" id="hora" value="<?php
$agora = date('H:i:s,-0300');
echo $agora
?>">
<input name="vendedor" type="hidden" id="vendedor" value="Diego">
<input name="status" type="hidden" id="status" value="Aberto">
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><i class="fas fa-times"></i> Fechar</button>
<input type="submit" class="btn btn-primary" value="Inserir Itens">
</div>
</form>
This is my Javascript:
<script>
function retornarColetas(data) {
var coletas = "";
$.each(data, function (chave, valor) {
var dataFormatada = valor.data.split('-').reverse().join('/');
coletas += '<tr>' +
'<td>' + valor.id_coleta + '</td>' +
'<td>' + valor.cliente + '</td>' +
'<td>' + dataFormatada + '</td>' +
'<td>' + valor.hora + '</td>' +
'<td>' + valor.vendedor + '</td>' +
'<td>' + valor.status + '</td>' +
'<td>' +
'<a class="btn btn-sm btn-outline-info text-info mr-2"><i class="fas fa-pencil-alt"></i> Editar</a>' +
'<a class="btn btn-sm btn-outline-danger text-danger"><i class="far fa-trash-alt"></i> Excluir</a>' +
'</td>';
});
$('#tabelaColeta').html(coletas);
}
$('#formColeta').submit(function (e) {
e.preventDefault();
var formulario = $(this);
var retorno = inserirColeta(formulario);
});
function inserirColeta(dados) {
$.ajax({
type: "POST",
data: dados.serialize(),
url: "config/insertcoleta.php",
async: "false"
}).then(sucesso, falha);
function sucesso(data) {
console.log(data);
}
function falha() {
console.log("erro");
}
}
</script>
What kind of column in Mysql? How is php that receives the form data and inserts it into the database?
– Damião Martins
Damião, these data are in a column of dataTables
– Diego Santos