Is this only if you have added your 'dob' field to the $dates array?
Date Serialization - Changes in Laravel 7
Hi,
I just upgraded from Laravel 6.x to 7.x. As mentioned in the Upgrade Guide the Date Serialization changed (at least for toArray and toJson).
I ran into an issue already. I store birthdates (dob) as date in my database. The format is YYYY-MM-DD. I would expect that the change of the serialization would not affect the date type but datetime. However, imagine your dob is the 2000-02-01, the new serialization will change it to 2000-02-01T00:00:00.000000Z and depending on your timezone, you might be one day younger 2000-01-31T22:00:00.000000Z
I guess the important information here is Please note that ISO-8601 dates are always expressed in UTC.
For the time being, I cast the dob to string. I honestly don't know if the serialization of the type date should be handled differently.
So, if you also stumble over this just cast it ;)
protected $casts = [
'dob' => 'string',
]
Of course casting to date is also an option
date:Y-m-d
Please or to participate in this conversation.