-1
I need to record the date and time in the bank, but the date returns me in this format 'Mon Jul 30 2018 00:00:00 GMT+0000' and in the bank is '0000-00-00 00 00:00', I recorded the same in a string and it is disarranged in the bank '1532995200000', I tried to format and make several Ambi, but it did not work.
Ajax sending data to PHP
$.ajax({
type: 'POST',
data: 'title='+title+'&start='+start+'&end='+end+'&allDay='+allDay,
url: 'agenda/acao.php',
success: function(data){
$('#title').val('');
}
});
Php that receives and writes data
$title = $_POST['title'];
$start = date('d/m/Y H:i:s', $_POST['start']);
$end = $_POST['end'];
try {
$stmt = $pdo->prepare("INSERT INTO events (title, start, end, teste) VALUES(?, ?, ?, ?);");
$stmt->bindValue(1, $title);
$stmt->bindValue(2, $start);
$stmt->bindValue(3, $end);
$stmt->bindValue(4, $start);
$stmt->execute();
} catch (PDOException $e) {
}
Could [Edit] the question and add the code?
– Woss
In which database you are trying to record, and what type of field you are using to store that date?
– Pedro Souza
Try to use the
STR_TO_DATE
mysql.– Francisco
Anderson Carlos Woss - This edited
– Ralf
Pedro Souza Mysql Field Datetime
– Ralf