简体   繁体   中英

Rails TimeZone in Production

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM