0

I am using Time.zone.now to get the user's time.

I think that this is wrong. Can you confirm that it is wrong? How can I get the user's time?

Who is setting Time.zone on my server?

Tony
  • 10,088
  • 20
  • 85
  • 139

1 Answers1

2

Yes this is wrong. Time.zone is whatever your application's timezone is set to. This is usually set in application.rb

config.time_zone = 'UTC'

If you want a user's timezone, you'll need to either get it from the client side via JavaScript or let the user set it themselves in your application.

Peter Brown
  • 50,956
  • 18
  • 113
  • 146
  • I have config.time_zone = "Pacific Time (US & Canada)" in my timezone but if I print Time.zone in a page it is showing my real timezone (which is not Pacific time), why? – Tony Aug 17 '12 at 15:56