Skip to content

How to store date/time as UTC but retrieve as localized date/time? #63

@GeminPatel

Description

@GeminPatel

Hi,

I was looking for a solution that will store my datetimes in UTC but on Application side will be in IST.
I have followed the guide and added use Timex.Ecto.Timestamps into my def model do in web.ex.

Now querying the Repo I get updated_at and inserted_at as #<DateTime(2017-06-05T05:40:55.030608Z Etc/UTC)>. Is there a way I can set some kind of config to serialize the datetime as IST. Also when I will insert I want to give IST to the changeset and it be properly converted and set in DB to UTC.

Going through the docs was not sufficient to find a solution to this problem.

I will create a MR to update docs if any solution such problem exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions