I'm trying to insert the datetime into a mysql column but I'm getting this error:
Error: INSERT INTO prices (priceLBTC, dt) VALUES (421.59, 2015-12-27 15:41:09) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '15:41:09)' at line 2
Here is the code I'm using to get the datetime and insert it into the "dt" datetime type column.
$dateTime = new DateTime();
$date = $dateTime->format('Y-m-d H:i:s');
$sql = "INSERT INTO prices (priceLBTC, dt)
VALUES ($bitcoinPrice, $date)";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$date. Alternatively, consider usingtimestamps