2

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

0

2 Answers 2

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

0

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

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

Credit goes here.

7
  • I want to store local time zone instead of heroku time zone Jun 25, 2015 at 18:47
  • Yes but I guess I don't understand the distinction. If you tell Heroku to use your local time, wouldn't that accomplish your objective? Jun 25, 2015 at 18:51
  • If i want to store to amazon ? Jun 25, 2015 at 19:06
  • So your app is running on Heroku, not your local machine, correct? If you interact with another service from your app, it is happening on the Heroku server. You are just controlling Heroku from your local machine (unless you have multiple prod apps, some on Heroku and some on your server...). Jun 25, 2015 at 19:09
  • Actually my app is on AWS. Ex: AWS time is 26-06-2015 and my local machine time is 25-06-2015. My requirement is to take the 25-06-2015 but it is taking 26-06-2015. Jun 25, 2015 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.