I am using laravel with a mysql localhost, when I insert a date in the input it will insert on db without any errors. But when the date input is empy I always have this error:
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: ''
What version of MySQL / Maria are you using? Also, are you inserting the date as '' or null?
When inserting as '' it will attempt to put 0000-00-00 00:00:00 and if you are on a newer version of the MySQL you might be running into strict mode errors. You could trying explicitly setting null or flipping the config in database.php
Operating system: Windows 10
Software Version: 10.1.16-MariaDB - mariadb.org binary distribution
I'm insert the date as '' so maybe the problem is here. But when I try to force as Null I get the same error.
I changed the strict to false and it works, but the problem is that is inserting '0000-00-00' and I want to be empty or null, also changing to false it's ok ? or I would have troubles in the future ?
Hmmm....definitely sounds like a Windows 10 thing to me. You will end up having troubles with this down the road IMO if you're coding your app to expect null instead of 0000-00-00. You might wanna try using a VM like Homestead if your machine can handle it. That way you won't run into those "it works on my machine" errors since you will essentially have a great production matched setup as your dev environment.
As for whether there is an actual fix for that, I'm not sure since I don't use Windows 10. Perhaps someone else does, but I would recommend going down the Homestead (or other VM) path.
I would highly suggest taking some of the beginner php lessons from Jeffrey, as this is just a basic sending a value to a function or could be a getter / setter, and returning a null to be stored if empty.