Support the ongoing development of Laravel.io →
Configuration Database Eloquent

I have a problem with postgres connection that not respect the config in app.php at timezone.

config/app.php

'timezone' => 'UTC',

My notebook (local server) is a timezone at Brasilia, but not is that want to use in my application. I want to use a UTC timezone, and I believe that if the connections to the database do not respect the application's timezone setting, then this is a Laravel 5 bug

I have a issue about this case:

http://stackoverflow.com/questions/43280254/laravel-5-configure-timezone-not-define-the-timezone-at-postgres-connection

My provisory solution in User model:

/**
 * Setting UTC timezone with mutator.
 *
 * @param $value
 * @return Carbon
 */
public function getLastLoggedInAtAttribute($value)
{
    return Carbon::createFromTimestampUTC(strtotime($value));
}

See more: http://stackoverflow.com/a/43283869/3332734

References:

https://laravel.com/docs/master/eloquent#eloquent-model-conventions

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.