I have a problem with the storage of zero date in the MySql database in the field of type timestamp. To read this field I use the Carbon library. When the value in database is equal 0000-00-00 00-00-00 Carbon converts it into a -0001-11-30 0:00:00. When saving to use a NULL value for the timestamp field. If I check if a date field is empty I must compare it to -0001-11-30 0:00:00. How can I solve this problem? Thank You!
If you have created the tables using migration
then for the date filed use nullable
method to allow null
value as default, for example:
$table->timestamp('dateFieldName')->nullable();
If you created the table using a differnt way then make sure that null value is allowed as default. Check this nice answer here for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With