Your timestamps are in UTC, but also in ISO8601, the standard for XML - where are they getting converted to ISO format?
Mar 23, 2020
4
Level 22
Wrong timezone returned by Laravel API, while tinker shows correct time
I have a problem with date in my Laravel projects - the date in the DB is not the date returned via api.
When I fetch the record from tinker, the updated_date is 2020-03-23 19:22:47. This is correct as per my timzone and the time when the event happened.
mathewparet$ php artisan tinker
Psy Shell v0.10.0 (PHP 7.3.11 — cli) by Justin Hileman
>>> App\User::find(4);
=> App\User {#3076
id: "4",
name: "Normal User",
email: "[email protected]",
email_verified_at: "2020-03-23 19:22:47",
created_at: "2020-03-23 19:21:44",
updated_at: "2020-03-23 19:22:47",
}
>>> exit
Exit: Goodbye
mathewparet$
I use the below code to retrieve the data in my controller and send to the browser as JSON:
public function index(Request $request)
{
$this->authorize('viewAny', User::class);
$users = User::all();
return compact('users');
}
However, the output, when caught at the browser end shows a different date:

The app timezone is set as:
'timezone' => 'Australia/Sydney',
Level 122
1 like
Please or to participate in this conversation.