Unable to set Heroku time zone

I need to have the display time of my application in the local time zone. Locally, I use 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 this does not apply to my application.

for instance

hero launch date : Launch date connected to the terminal ... up, launch .4786 Tue 23 Apr 15:13:51 EEST 2013

heroku launch console :

Order.last.created_at => Tue, April 23, 2013 13:15:53 ​​EEST +03: 00

Time.zone => (GMT + 02: 00) Athens

But I put this in my tracks: <% = Time.zone%> And I understand: (GMT + 00: 00) UTC And my times appear in UTC in a real application.

So, how to set the time zone for a real rail application on heroku (and not just on the console).

+4
source share
2 answers

Try setting the time zone in 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 outputting dates and times from the database. The default value is: utc for Rails, although the default value for Active Record is: local when used outside of Rails.

from: http://guides.rubyonrails.org/configuring.html#configuring-active-record

+10
source

Have you tried setting the time zone in application.rb as described here ?

  config.time_zone = 'Eastern Time (US & Canada)' config.active_record.default_timezone = 'Eastern Time (US & Canada)' 
0
source

All Articles