I have a project on the web and I am trying to save the complete date in the database but it is giving me a strange error, I do not understand what the error is.
Note: Recently everything was going well because in my database in the field where I saved the date was type DATE
and I realized that I need the full date with hours and minutes, then I changed the format to DATETIME
after I changed it also changed the function of the date, here you will see an example
$fecha=date('Y-m-d');//antes
$fecha=date('Y-m-d H:i:s');//nueva
I clarify that I am working with prepared queries and this is the way I insert the information
$query=$con->prepare("INSERT INTO noticias (titulo,fecha)VALUES(?,?)");
$sql->bind_param("sd", $titulo,$fecha);
if($sql->execute()){
$sql->close();
echo"exito";
}else{
echo"error ".mysqli_error($con)
}
The error that throws me is the following
Error: Incorrect datetime value: '2018' for column 'date' at row 1