We have a project that is hosted in one time zone (say, Pacific Daylight Time) but the client wants all time recorded in their time zone (say, Mountain Time). What is the best way to do this? Any recommendations? Thanks! Justin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060602/b995e232/attachment.html
On 03/06/2006, at 4:08 AM, Justin Bailey wrote:> We have a project that is hosted in one time zone (say, Pacific > Daylight Time) but the client wants all time recorded in their time > zone (say, Mountain Time). What is the best way to do this? Any > recommendations? Thanks!Storing time in the database in a zone other than the server''s zone or UTC is difficult. You probably want to store all times as UTC, and then convert them to the appropriate zone on output. In environment.rb, you''ll need: config.active_record.default_timezone = :utc And then take a look at TZInfo (http://tzinfo.rubyforge.org/) for doing timezone conversions. Cheers, Pete Yandell http://9cays.com/
> Storing time in the database in a zone other than the server''s zone > or UTC is difficult. You probably want to store all times as UTC, and > then convert them to the appropriate zone on output. >An approach that has worked well for me is to store all times in UTC, build HTML pages in UTC, then use Javascript on the client side to convert all the times to browser-local time before display. cf. http://mikewest.org/archive/showing-perfect-time-unobtrusively Regards, Danny -- Posted via http://www.ruby-forum.com/.
These are great answers. Thanks for your help, both of you! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060603/a84c1eaa/attachment-0001.html
Seemingly Similar Threads
- TimeWithZone seems in rails 2.3 seems broken...is this the correct behavior?
- Setting default timezone ENV[''TZ'']=''UTC'' not working on windows?
- Some timezone trouble involving tzinfo and postgresql
- RSpec Testing ActiveRecord config dependency.
- Time zone mapping from TimeZone to TZInfo::Timezone