In application.rb
, it says:
Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
But setting config.time_zone = 'Central Time (US & Canada)'
or config.time_zone = 'Eastern Time (US & Canada)'
has no effect - the created_at
field in a model is stil being saved in UTC.
According to this railsforum answer:
config.time_zone just lets rails know that your server is set to this timezone so when it writes dates to the database it can properly convert it to UTC.
If that is true, then why is it that when my system time is Pacific Time (US & Canada)
and config.time_zone = 'Central Time (US & Canada)'
or config.time_zone = 'Eastern Time (US & Canada)'
, that the created_at
time is the correct UTC? Should it not be incorrect?!
Because, if the PST time is 8 PM, then EST is 11 PM and UTC is 4 AM.
Presuming that Rails does Time.now
, that would be 8 PM. And we told Rails that the server is in EST. So, 8 PM would be EST time as far as Rails is concerned and the UTC would then be 5 AM UTC, which would be incorrect (because the actual time is 8 PM PST/11 PM EST, which is 4 AM UTC)
What's going on here?