How to convert the time in milliseconds to Ecto.DateTime
?
The time in milliseconds is the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
To convert timestamps to DateTime
DateTime.from_unix(1466298513463, :millisecond)
For more Details https://hexdocs.pm/elixir/master/DateTime.html#from_unix/3
Now it's very simple to do:
timestamp |> DateTime.from_unix!(:millisecond) |> Ecto.DateTime.cast!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With