# TimeZone confusion

**URL:** <https://www.ruby-forum.com/t/timezone-confusion/164115>\
**Category:** Rails\
**Created:** [March 28, 2009, 3:01am UTC](https://www.ruby-forum.com/t/timezone-confusion/164115 "2009-03-28T03:01:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![suer\_rick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@suer\_rick](https://www.ruby-forum.com/u/suer_rick)\
**Post date:** [March 28, 2009, 3:01am UTC](https://www.ruby-forum.com/t/timezone-confusion/164115/1 "2009-03-28T03:01:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![suer\_rick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@suer\_rick](https://www.ruby-forum.com/u/suer_rick)\
**Post date:** [March 28, 2009, 7:22am UTC](https://www.ruby-forum.com/t/timezone-confusion/164115/2 "2009-03-28T07:22:18Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![suer\_rick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@suer\_rick](https://www.ruby-forum.com/u/suer_rick)\
**Post date:** [March 28, 2009, 3:34pm UTC](https://www.ruby-forum.com/t/timezone-confusion/164115/3 "2009-03-28T15:34:50Z")

</div>

That line was already there, and is not commented.

On Mar 28, 2:22 am, Danny B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![suer\_rick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@suer\_rick](https://www.ruby-forum.com/u/suer_rick)\
**Post date:** [March 28, 2009, 7:49pm UTC](https://www.ruby-forum.com/t/timezone-confusion/164115/4 "2009-03-28T19:49:10Z")

</div>

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?
