mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
https://www.mongodb.com/docs/drivers/php/laravel-mongodb/
MIT License
7.02k stars 1.43k forks source link

Library saving dates ignoring timezone application #2338

Open ceresaconsultoria opened 2 years ago

ceresaconsultoria commented 2 years ago

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)
joaovitoralvares commented 2 years ago

@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)

ceresaconsultoria commented 2 years ago

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: @.***>