set created_at with local time zone in rails

时间:2015-06-25 18:24:02

标签: ruby-on-rails ruby-on-rails-3

Set the created_at to local time zone. I deployed my app in heroku. But while creating creating record created_at is taking heroku time but not local time. For example: in heroku time is: 26-06-2015 but in my local machine time is: 25-06-2015

I want to store my local machine time not heroku time. I tried to put the below code in application.rb

  config.time_zone = 'Eastern Time (US & Canada)'
  config.active_record.default_timezone = :local

But not working. Can anyone help me out of this

2 个答案:

答案 0 :(得分:1)

Alternatively try this config.time_zone = 'Eastern Time (US & Canada)' config.active_record.default_timezone = 'Eastern Time (US & Canada)' Here the reference Hope it helps

答案 1 :(得分:0)

To set time zone on the Heroku server, you will need this:

$ heroku config:add TZ="America/New_York"

Credit goes here.