About the timezone question

I am using centos, already set the timezone is Thu, 03 Nov 2016 09:29:21 +0800 , When i started the phoenix server and IO.puts the current time use Ecto.DateTime.utc DateTime.utc_now or Timex.now , Its showing 2016-11-03 01:29:26.016300Z , This is decrease 8 hours, I want get the now time equals my centos time, what function to use in timex. thanks

1 Like

Local time as in local to the server? Local to the users browser? Local to something else?

Timex can do all of that. UTC is standard time encoding, you convert to the timezone that you want to display it in, of which there are many to choose from. :slight_smile:

1 Like

There is no discrepancy in both time values (OK, there is a difference of 5 roughly 5 seconds).

The Z at the end of the time means +0000. You can save yourself a lot of confusion later on, when you do use only UTC throughout your system, but display (and only display) to the user whatever he wants to see.

1 Like