I am trying to build a simple function where I want to fetch a DateTime from database that is stored in UTC format and display it to the user in their local timezone. I found heaps of solutions that works, but the timezone is not correct.
$time = Carbon::createFromFormat('Y-m-d H:i:s', $user->created_at)->settings(['timezone' => 'Australia/Sydney']);
So this code takes in $user->created_at , "created_at": "2021-12-02T21:18:31.000000Z", which in UTC format created on 21:18, which is 8:18 am in Sydney, yet, when I run the code i get a wrong time zone, "2021-12-02T10:27:29.000000Z", which is 10:27 am.
I am not sure whats happening. Any Help will be greatly appreciated
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3pk1aIp
via IFTTT
Aucun commentaire:
Enregistrer un commentaire