What is your Laravel version? See https://laravel.com/docs/7.x/upgrade#date-serialization
Because my date ends with ".000000Z"
I'm having trouble displaying the notification date correctly.
In the laravel notification table, the date is stored correctly like this: 2020-09-14 15:28:21
But when I get this date for display, it is returned like this: created_at: "2020-09-14T15: 28: 21.000000Z"
So my date appears correct on the display, but the time is never the same.
I'm doing this to capture notifications:
$notifications = $request->user()->notifications()
->limit(7)
->get()
->each(function ($notification) {
$notification->formatted_created_at = $notification->created_at->format(__('notifications.dateformat'));
});
And I get this:
0:
created_at: "2020-09-14T15:28:21.000000Z"
data: Object
formatted_created_at: "14/09/2020 03:09:21"
id: (...)
notifiable_id: (...)
notifiable_type: (...)
read_at: (...)
type: (...)
updated_at: (...)
Formatted_created_at doesn't seem to be forming the date correctly due to this strange format in created_at (but the database is correct).
That is, when it comes to listing the notifications, the date appears correct, but the time always returns 03:09 and only the seconds vary, that is:
03:09:08 | 03:09:31 | 03:09:54 ...
What is happening ?
I found the solution in this topic: https://laracasts.com/discuss/channels/laravel/laravel-7-notification-timestamps-serialization
Please or to participate in this conversation.