0

how to get IST time in heroku using rails app

config.active_record.default_timezone = :local

inside the config/environments/development.rb.The above code changed the timezone from UTC to IST.

inside config/environments/production.rb

config.active_record.default_timezone = :local

its not working in heroku why? how can i get the IST time.

raja
  • 15
  • 7

1 Answers1

0

:local gives the local time of the location the server is currently present. So, in development it's giving the IST time but on Heroku it's giving the UTC as server isn't in India.

you can use config.time_zone = 'New Delhi' in application.rb to get the time in IST.

Gagan Gupta
  • 1,189
  • 7
  • 19
  • /config/application.rb:3:in `': undefined local variable or method `config' for main:Object (NameError) i get the error when i used the above code inside my application.rb file – raja Apr 21 '18 at 09:41
  • define it inside `class Application < Rails::Application` or you can share your application.rb code I will help you in defining it. – Gagan Gupta Apr 21 '18 at 10:01
  • I am using the above code, it also pretty work in local but in heroku not working it stores the same UTC value. I din't get the IST value in heroku. so help me – raja Apr 21 '18 at 10:33
  • Add `config.active_record.default_timezone = 'New Delhi` under above line – Gagan Gupta Apr 21 '18 at 11:02