Define timezone database

Where should I set up timezone so that my database records the creation date and update with my timezone?

The first answer to this StackOverflow question is helpful

Inside Adonis is there any configuration I can do?

I have a record that has the date 2019-04-25 15:10:00 and date is correct for my region … however lucid returns me 2019-04-25 12:10:00

If your RDBMS is set to the right timezone then you are halfway to solve the issue because it is easy to manipulate dates in Models.

Here are two things you need to know to solve your issue:

It seems you are experienced, so you have all what you need to do it yourself, otherwise let me know and I will write a tutorial about it on this weekend.

1 Like

Thanks @begueradj

1 Like

Please @begueradj give us some clues! I’ve struggling with this like 3 days already… Already seen this one solution that adds pool option to the connection object at config/database.js:

 pool: {
        afterCreate: function(connection, callback) {
          connection.query('SET time_zone = "UTC+4";', function(err) {
            callback(err, connection);
          });
        }
      }

and still not working. PLease, help! Thanks in advance!

Hi, add in .env

TZ=‘America/Brasilia’

is works

[ ]'s

3 Likes

Why not just store the dates in UTC format then convert it to the local time zone on the client side?

Vlw mano
Salvou