当前位置: 动力学知识库 > 问答 > 编程问答 >

How to Store Time in Ruby/Rails other than local or utc

问题描述:

I have a unique situation. We are running a hosted application with a different Rails environment for each customer so I don't maintain multiple copies of the code base. Each customer is in a different time zone and I have to store the time in that timezone for our desktop application to work properly. I can't change the system time to match since there are multiple instances running on the same server. My question is I know I can do this:

config.active_record.default_time_zone = :utc

or this:

config.active_record.default_time_zone - :local

Is there anyway I can do this?

config.active_record.default_time_zone = 'Mountain Time (US & Canada)'

and still have the system clock be Central Time?

BTW we are using SQL Server and JRuby

网友答案:

You should store time in database in UTC format, also keep each users timezone settings in the database.

Keep in mind, that SQL server can have its own timezone settings, so you should configure it properly too.

分享给朋友:
您可能感兴趣的文章:
随机阅读: