Laravel automatically passes the created_at
and the updated_at
(from an Eloquent model) into a new Carbon instance, as per the documentation.
It seems though, that if the value is the default 0000-00-00 00:00:00
it outputs the following:
-0001-11-30 06:12:32
for all 0000-00-00 00:00:00
values.
The fields are set to timestamp type.
I'm using the following at the moment (within the model), but it feels clumsy to have to do this across all Laravel models that may contain a default/unset date.
public function getCreatedAtAttribute($value) {
return $value == "0000-00-00 00:00:00" ? "0000-00-00 00:00:00" : $value;
}