Brazil date issue


Since this year, Brazil is no longer part of Daylight Saving Time timezones, and the locale “America/Sao_Paulo” returns a UTC-2 value (I don’t know who can update this, but i’ts outdated).

All my dates are with 1hour difference from the real time in my state (UTC-3), and this is confusing me.

I’ve tried to change the default PostgreSQL timezone with a UTC-3 value, it works, but only updates the dates in my DB, when I use the toJSON()method in my models, dates goes back to the old wrong timezone.

So, I was searching in Adonis’ source code to found where dates are formatted, and I found this:


   * This method is executed for all the date fields
   * with the field name and the value. The return
   * value gets saved to the database.
   * Also if you have defined a setter for a date field
   * this method will not be executed for that field.
   * @method formatDates
   * @param  {String}    key
   * @param  {String|Date}    value
   * @return {String}
  static formatDates (key, value) {
    return moment(value).format(DATE_FORMAT)

I changed the code to use the correct timezone:

static formatDates (key, value) {
    return moment(value).utcOffset('-0300').format(DATE_FORMAT)

When I use the utcOffset() method, I can get the correct date

How I can achieve this without changing the source code of AdonisJs?

1 Like

@virk Any help with this?

Caramba. Isso é um problema. Mas eu acredito que o problema esteja na máquina, visto que os servidores pegam a data diretamente dela.

1 Like

In this case, the problem is on my local machine, i haven’t tested in production yet…

All other software dates in my MacOS are ok, just Adonis and PostgreSQL are with wrong datetimes…

Do you have any tip about how to fix it?

I put in the model and it worked for me, adjusted the time.

static castDates (field, value) {
  return value.utcOffset(-1, true).format()
1 Like

Well, this isn’t working :frowning:

Hour is still ahead from real time…

Hi, Add line in .env


[ ]'s


I’ll try this soon

But i already tried with TZ='America/Sao_Paulo', and it didn’t worked

Yeah, i tried the “America/Brasilia” timezone, and it’s still not working

Anybody knows how to fix this issue?

@virk Maybe updating adonis core libraries would fix this?

Still no solution for this…

Try this…

const {subHours} = require('date-fns');
const utcBrazil = subHours(new Date(), 3);
1 Like