Jeremy Woertink wrote in post #1099164:
> The issue I'm running into is that when someone selects "Pacific Time
> (US & Canada)" the value of that option is "-0800". If the date they
> selected is after March 10th (2013), then the "Pacific Time (US &
> Canada)" time zone is actually "-0700". So what happens is they save the
> record as 2013-03-15 08:00 pm -0800, then it gets stored in the DB as
> Fri, 15 Mar 2013 21:00:00 PDT -07:00.

I think that's problem #1. In order to provide global timezone support 
you should store all date/time values in UTC in the database and 
translate the date/time into the local timezone of the server.

It is also often necessary to display dates and time in the local time 
zone of the user, which means you'll need to ask the user their time 
zone and store that with the user.

Example:
2013-03-15 08:00 pm -0800 => 2013-03-15 16:00:00 UTC

Now timezone is no longer an issue... UTC is UTC everywhere, that's the 
point. If configured properly Rails should take care of this for your 
automatically.

If you do need to display the time in the local time zone of the user 
then you can.

utc_time.in_time_zone("Pacific Time (US & Canada)")

Note: in_time_zone is a Rails convenience.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to