3

I have my Linux server in New York, configured to GMT.

All my dates are being saved in UTC.

To return these dates to client, the only thing I need to do is ?

date = my_date.utc_to_local 

No matters where my client is in the world ?

Do Rails knows where my client is ?

Beetlejuice
  • 4,292
  • 10
  • 58
  • 84

1 Answers1

1

By default, Rails will always store the date/times in UTC. If you don't like that, you can change it like this:

class Application < Rails::Application
  config.active_record.default_timezone = :local
end

No matter how the date/times are stored in the database it will always convert it to the application default timezone:

For example:

class Application < Rails::Application
  config.time_zone = 'Eastern Time (US & Canada)'
end

I hope that helps! Let me know if you want more details!

Tom Rossi
  • 11,604
  • 5
  • 65
  • 96
  • Hi Tom, I´ve got this to work, partially, last week. I have some problems with TIME fields that I use to store only hours. I was seriously thinking to change all my TIME columns to DATETIME. – Beetlejuice Nov 20 '15 at 10:34