Forum: Ruby on Rails TimeZone confusion

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Rick S. (Guest)
on 2009-03-28 04:01
(Received via mailing list)
I'm using rails 2.3.2.

I have Date/Time data stored in a SQL Server database.  All values are
UTC (although the database just stores the time, not the zone).  All
of my computers are in the America/New York time zone.

It was my understanding that rails expects a UTC time to come from the
database.

But, it looks like rails assumes that the time value is really local
(in my case, UTC - 5 hours) and converts it by adding 5 hours.  Which
is not what I want.

How can I tell rails that the times *are* UTC and to leave them alone?
Danny B. (Guest)
on 2009-03-28 08:22
> How can I tell rails that the times *are* UTC and to leave them alone?

Put

  config.time_zone = 'UTC'

in your environment.rb.  Actually if you look closely, it's probably
already there, just commented out by default.

- D
Rick S. (Guest)
on 2009-03-28 16:34
(Received via mailing list)
That line was already there, and is not commented.

On Mar 28, 2:22 am, Danny B. <removed_email_address@domain.invalid>
James B. (Guest)
on 2009-03-28 20:49
Rick S. wrote:
> I'm using rails 2.3.2.

> But, it looks like rails assumes that the time value is really local
> (in my case, UTC - 5 hours) and converts it by adding 5 hours.  Which
> is not what I want.
>
> How can I tell rails that the times *are* UTC and to leave them alone?

How are you "looking" at the database values?
This topic is locked and can not be replied to.