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

Rebel Rider
  • 165
  • 16

2 Answers2

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

Community
  • 1
  • 1
Prashant4224
  • 1,551
  • 1
  • 14
  • 21
0

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

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

Credit goes here.

steve klein
  • 2,566
  • 1
  • 14
  • 27
  • I want to store local time zone instead of heroku time zone – Rebel Rider Jun 25 '15 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? – steve klein Jun 25 '15 at 18:51
  • If i want to store to amazon ? – Rebel Rider Jun 25 '15 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...). – steve klein Jun 25 '15 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. – Rebel Rider Jun 25 '15 at 19:44
  • So what does Heroku have to do with it? – steve klein Jun 25 '15 at 19:51
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/81573/discussion-between-steve-klein-and-sunny). – steve klein Jun 25 '15 at 19:53