I need to have my app display times in a local timezone. Locally I'm using Time.zone = "Athens" in application.rb and it works fine.
For Heroku I used "heroku config:add TZ=Europe/Athens". This works fine for every operation I do from the command line, but it doesn't apply to my app.
For example
heroku run date:
Running date
attached to terminal... up, run.4786
Tue Apr 23 15:13:51 EEST 2013
heroku run console:
Order.last.created_at => Tue, 23 Apr 2013 13:15:53 EEST +03:00
Time.zone => (GMT+02:00) Athens
But I put this in my rails view: <%= Time.zone %> And I get this: (GMT+00:00) UTC And my times appear in UTC time in the actual app.
So, how do I set the timezone to apply to the actual rails application on heroku (and not just the console).
Try to set the time zone in your application.rb as follows:
config.time_zone = 'Athens'
config.active_record.default_timezone = :local
config.active_record.default_timezone determines whether to use Time.local (if set to :local) or Time.utc (if set to :utc) when pulling dates and times from the database. The default is :utc for Rails, although Active Record defaults to :local when used outside of Rails.
from: http://guides.rubyonrails.org/configuring.html#configuring-active-record
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