Rebel Rider
Rebel Rider

Reputation: 167

set created_at with local time zone in rails

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

Upvotes: 2

Views: 1299

Answers (2)

Prashant4224
Prashant4224

Reputation: 1601

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

Upvotes: 1

steve klein
steve klein

Reputation: 2629

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

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

Credit goes here.

Upvotes: 0

Related Questions