laravel-mongodb icon indicating copy to clipboard operation
laravel-mongodb copied to clipboard

Library saving dates ignoring timezone application

Open ceresaconsultoria opened this issue 3 years ago • 2 comments

  • Laravel-mongodb Version: #.#.#
  • PHP Version: 7.4.27
  • Database Driver & Version: 1.12.0

Description:

Steps to reproduce

  1. set date_default_timezone_set("America/Sao_Paulo")
  2. record in database one register with datetime
  3. check record registred timezone america +3 not America/Sao_Paulo

Expected behaviour

Record registred with timezone configured from system

Actual behaviour

Record registred with timezone diferente from timezone configured from system

Logs: Insert log.txt here (if necessary)

ceresaconsultoria avatar Jan 25 '22 13:01 ceresaconsultoria

@ceresaconsultoria Dates in MongDB are always stored in UTC. When you set the timezone to America/Sao_Paulo, it will be converted to UTC before the record is saved. For instance, if you store a record with date 2022-05-10 16:28:00 ( America/Sao_Paulo -03:00), the date stored in database will be 2022-05-10 19:28:00 (UTC +00:00)

joaovitoralvares avatar May 10 '22 19:05 joaovitoralvares

Hi

thanks for response.

Atenciosamente,

Em ter., 10 de mai. de 2022 às 16:33, joaovitoralvares < @.***> escreveu:

@ceresaconsultoria https://github.com/ceresaconsultoria Dates in MongDB are always stored in UTC. When you set the timezone to America/Sao_Paulo, it will be converted to UTC before the record is saved. For instance, if you store a record with date 2022-05-10 16:28:00 ( America/Sao_Paulo -03:00), the date stored in database will be 2022-05-10 19:28:00 (UTC +00:00)

— Reply to this email directly, view it on GitHub https://github.com/jenssegers/laravel-mongodb/issues/2338#issuecomment-1122784318, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANMHJ2FAQUZKGIKDNFJIA23VJK2X5ANCNFSM5MYHUFFQ . You are receiving this because you were mentioned.Message ID: @.***>

ceresaconsultoria avatar May 11 '22 11:05 ceresaconsultoria