Where should I set up timezone so that my database records the creation date and update with my timezone?
Define timezone database
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:
- AdonisJs uses Moment.js internally, so you can ask your models to format your dates as you want: How to use Moment.js with AdonisJs
- The second thing you need to know is
utcOffset()
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.
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
Why not just store the dates in UTC format then convert it to the local time zone on the client side?
Vlw mano
Salvou