Save Date in UTC Brazil Table

Asked

Viewed 332 times

1

I’m making an insert into a Mysql table that contains several date fields.

I left in the default column created_at table the value current_timestamp.

If I make one INSERT now, it is inserting: 12:29:00. That is, three more hours.

And if I do the INSERT in this column manually by Laravel, so:

$model->created_at = date('Y-m-d H:i:s')

It also inserts with three hours more.

How do I fix it ?

2 answers

2

One way to resolve this globally is to define the appropriate Timezone(America_sao_paulo) in php.ini.

Search or create this line in php.ini and restart apache after the change.

date.timezone=America/Sao_Paulo

2


Can go to config/app, and change the timezone:

'timezone' => 'America/Sao_Paulo',

I believe that this already solves your problem, I leave here the list of American timezones, I think it must be one of these that wants

  • Good. I didn’t even remember that parade.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.