Zero Label in Database - Carbon
I have a problem storing a null date in a MySql database in a field of type timestamp. To read this field, I am using the Carbon library. When the value in the database is 0000-00-00 00-00-00 Carbon turns it into -0001-11-30 0:00:00. When storing, NULL is used for the timestamp field. If I check if the date field is empty, I have to compare it with -0001-11-30 0:00:00. How can I solve this problem? Thank!
source to share
If you created tables with migration
then for the supplied date use the method nullable
to allow the null
default, e.g .:
$table->timestamp('dateFieldName')->nullable();
If you created the table using the differnt method make sure null is allowed by default. See this nice answer here for more information.
source to share