what if remove
// 'created_at' => 'datetime:Y-m-d H:i:s',
I have a model with sessions belonging to a user. In the Session model i've added:
protected $casts = [
'items' => 'array',
'created_at' => 'datetime:Y-m-d H:i:s',
];
when I print out the session.created_at it returns the wrong hour. My initial idea was that this must be a timezone issue, so I set 'timezone' => 'Asia/Singapore', in app.php and cleared the caches. But still I get a wrong hour. When I dump out the carbon date (dd(Carbon::now())) it show the right time, when I look at the database field, its also correct (sqlite).
it shows 2021-01-06 11:20:52, without the cast it shows 2021-01-06T11:20:52.000000Z, by database field shows 2021-01-06 19:20:52 (correct) and the Carbon dump shows date: 2021-01-06 19:51:11.161307 Asia/Singapore (+08:00) (which is the correct time now)
I have the feeling I am overlooking something very obvious, but I just can't figure it out.
Anybody see whats wrong here?
In the end I was not able to figure out where the problem was, so I ended up using the MomentJs library and formatted the date in the frontend after all.
I would be happy to hear any solution, but for now I guess I'll stick to this.
Please or to participate in this conversation.