What is the difference between config.time_zone and config.local_zone? Is there a situation when should both be set?
What is the difference between config.time_zone and config.local_zone ? Is there a situation when
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1)
config.time_zoneRails gives your ability to configure application time zone. It’s as easy as
Time.zone = 'EST'.So setting
config.time_zonein yourapplication.rbwill eventually do the same. And this is the right thing to do since we don’t want to depend on server time zone.In your
application.rb(Rails 3) file, you can set the default timezone:2)
config.local_zoneIt displays the system local time.
So if you really must have local time in the db then lie to Rails by
setting
config.time_zoneto UTC, this tells it that it is to assumethat timestamps are already in UTC so it will not need to change them
to get them into what it thinks is UTC.
config.active_record.default_timezonedetermines whether to useTime.local(if set to :local) orTime.utc(if set to :utc) when pulling dates and times from the database. The default is:utcfor Rails, although Active Record defaults to:localwhen used outside of Rails.