1

My Server is USA West Coast but all the time that is recorded in the MySQL server should be done in UTC so that i can implement TimeZone for Users at the later date. Right now Configuring to Indian Timing.

Is there any configuration i need to do to get this working. i have added the following:

//application.rb
config.time_zone = 'UTC'
config.active_record.default_timezone :utc

Is there any other settings i need to do to tell rails that please save content in the UTC?

Harsha M V
  • 54,075
  • 125
  • 354
  • 529
  • This may help you. http://stackoverflow.com/questions/28226367/how-to-handle-mysql-timezone-in-script/28227116#28227116 – O. Jones Feb 18 '15 at 12:58
  • 1
    Can you use the `TIMESTAMP` data type? (Do all the timestamps in your system lie between 1970 and 2037?) If you're already using that data type, your times are already stored in UTC. – O. Jones Feb 18 '15 at 12:59

1 Answers1

1

In rails application the time recorded in MySQL is automatically taken in UTC. What happens is when you give config.time_zone = 'UTC' in application.rb, the rails converts that time from UTC (stored in MySQL) to the timezone specified in application.rb. So I think there is nothing required to do that.

Hope this helps.

Deepesh
  • 6,138
  • 1
  • 24
  • 41